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.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
final selectName = //field depending on current select list value
def cfManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def currentField = getFieldById(getFieldChanged())
String valCurrent = currentField.value.toString()
// field to update
def cfDepends = cfManager.getCustomFieldObjectsByName('SubSelectList')[0]
def dependingField = getFieldByName(selectName)
// Make sure the fields we want to work with are on the form
if (!currentField && !dependingField) {
return
}
// Must grab the relevant config given the current issue context and the custom field
def config = ComponentAccessor.fieldConfigSchemeManager.getRelevantConfig(issueContext, cfDepends)
// Given config, grab a map of the possible options for the second select custom field
def 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 set
if (!options) {
return
}
switch (valCurrent) {
case '1':
dependingField.setFieldOptions(options.findAll { it.value in optionSet1 }.collectEntries {
[(it.optionId): it.value]
})
break
case '2':
dependingField.setFieldOptions(options.findAll { it.value in optionSet2 }.collectEntries {
[(it.optionId): it.value]
})
break
case '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 of
default:
dependingField.setFieldOptions(options)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.