Forums

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

Set Custom Field Value to a Cascading Dropdown field Scriptrunner

Rajaravikiran S August 16, 2020

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.

2 answers

1 vote
Bhanu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2020

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

1 vote
Bhanu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2020

Hi Rajaravikiran,

For the single list drop down you can use the following script.

{code}

// set a desired value in a single select list field
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

def cf = customFieldManager.getCustomFieldObject("customfield_xxxxx") // replace xxxxx with your customfield id
def 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)

{code}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events