Behaviour script to set single select list field not working

BBS December 16, 2019

Hi,

i am using the below code in the behaviours to set the value for the field select list based on the value of the other field,

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.config.FieldConfig;

 

def productField=getFieldById(getFieldChanged());

def qaCertField = getFieldById('customfield_13944');

def pnv = pnvField.getValue() as ArrayList<String>;

 

if(pnv.size()>0 ){

String product = pnv.get(0);
def customFieldQACert = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('customfield_13944')

def fieldConfigQACert = customFieldQACert.getRelevantConfig(getIssueContext());

OptionsManager optionsManagerQACert = ComponentAccessor.getOptionsManager();

def optionsQACert = optionsManagerQACert.getOptions(fieldConfigQACert);

def optionQACert;

if(product == "Apple") {
optionQACert = optionsQACert.find {it.value == "Yes"}
qaCertField.setFormValue(optionQACert.optionId);
}else{
optionQACert = optionsQACert.find {it.value == "No"}
qaCertField.setFormValue(optionQACert.optionId);

}
}

0 answers

Suggest an answer

Log in or Sign up to answer