Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set value to a field converted into single Select through Script Runner

ashwani kabra June 8, 2022

Hi All,

 

I created a text field and converted it into a single Select by populating the master data list fetched from the rest endpoint. Behavior script converts into single select on page initialize.

 

Now fetch some data from other rest endpoint and populate to multiple fields, however not able to populate the value to this single select field since it is converted through script runner.

 

The value i'm populating ( set form value ) to this field is already part of the select list options. 

Please advise.

on initialise script in behaviour :

getFieldByName("vendors").convertToSingleSelect([
ajaxOptions: [
url : "http://localhost:8080/rest/scriptrunner/latest/custom/VendorTypes",
query: true, // keep going back to the sever for each keystroke
minQueryLength: 0,
keyInputPeriod: 500,
formatResponse: "general",
]
])

 

Second Behaviour script (Server Side0:

 

if(lotControl!=null){
def field = getFieldByName(vendorFieldName)
def optionsManager = ComponentAccessor.getOptionsManager()

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(vendorFieldName)
def fieldConfig = customField.getRelevantConfig(getIssueContext())

def options = optionsManager.getOptions(fieldConfig)

def option = options.find {it.value== lotControl}
field.setFormValue(option.optionId)

}

1 answer

0 votes
MF
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 12, 2024

maybe this is works:

def options = [:]
options << [(lotControl):(lotControl)]
field.setFieldOptions(otions)
field.setFormValue(lotControl)

without "optionsManager"

Suggest an answer

Log in or Sign up to answer