I have a custom screen where a custom field Single select list options depends on other cf single select value set by parent issue.
I used Dynamic Select script from Adaptavist library in behaviour, I tryed either in initializer and in field server side script, but it don't works.
Any suggestions?
Hi @Katia Castiglioni _Hel Maedb_ ,
please, in order to help you, could you share your script? BTW, you should put your script in the field from which select list depend.
Fabio
I put my script in the field from which select list depend, but it doesn't works. The script is copied from Dynamic Select script by Adaptavist Library:
import com.atlassian.jira.component.ComponentAccessorimport com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScript@BaseScript FieldBehaviours fieldBehavioursfinal selectName = //field depending on current select list valuedef cfManager = ComponentAccessor.customFieldManagerdef optionsManager = ComponentAccessor.optionsManagerdef currentField = getFieldById(getFieldChanged()) String valCurrent = currentField.value.toString()// field to updatedef cfDepends = cfManager.getCustomFieldObjectsByName('SubSelectList')[0]def dependingField = getFieldByName(selectName)// Make sure the fields we want to work with are on the formif (!currentField && !dependingField) {return}// Must grab the relevant config given the current issue context and the custom fielddef config = ComponentAccessor.fieldConfigSchemeManager.getRelevantConfig(issueContext, cfDepends)// Given config, grab a map of the possible options for the second select custom fielddef options = optionsManager.getOptions(config)def optionSet1 = ['a', 'b', 'c']def optionSet2 = ['d', 'e']def optionSet3 = ['f', 'g']// Make sure the second field actually has options to setif (!options) {return}switch (valCurrent) {case '1':dependingField.setFieldOptions(options.findAll { it.value in optionSet1 }.collectEntries {[(it.optionId): it.value]})breakcase '2':dependingField.setFieldOptions(options.findAll { it.value in optionSet2 }.collectEntries {[(it.optionId): it.value]})breakcase '3':dependingField.setFieldOptions(options.findAll { it.value in optionSet3 }.collectEntries {[(it.optionId): it.value]})break// Reset to default options if single select option is null or any other option that is not taken care ofdefault:dependingField.setFieldOptions(options)}
It looks like you're new here. Sign in or register to get started.