Could anyone please help me with the code of setting cascading drop-down custom field value as well as single list dropdown using ScriptRunner in Jira workflow post functions.
Hi Rajaravikiran,
For the single list drop down you can use the following script.
{code}
// set a desired value in a single select list fieldimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.issue.CustomFieldManager
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject("customfield_xxxxx") // replace xxxxx with your customfield iddef optionsManager = ComponentAccessor.getOptionsManager()def fieldConfig = cf.getRelevantConfig(issue)def option = optionsManager.getOptions(fieldConfig).find {it.value == "xxxxx"} // replace xxxxx with the value you want to set in the field
issue.setCustomFieldValue(cf, option)
For the cascading select list please check the Adaptavist script library https://library.adaptavist.com/entity/set-a-default-option-on-a-cascading-select-list
It looks like you're new here. Sign in or register to get started.