Hello, I'm not very familiar with scripting but I would like to leverage ScriptRunner Behavior to show only certain options from an Insight custom field based on a previous selection from a Jira custom field select list. Is this possible? It doesn't seem to be working when I manipulate an existing script (below) that we've used for non-Insight fields.
Thanks in advance for any assistance you can offer.
_____________________________________________________________________________________
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
int biactionId = 17401
def biaction = getFieldById("customfield_17401")
def biactionValue = biaction.getValue()
int bitypeId = 17513
def bitype = getFieldById("customfield_17513") //Insight custom field
def optionsManager = ComponentAccessor.getOptionsManager()
def bitypeCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(bitypeId)
def bitypeConfig = bitypeCustomField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(bitypeConfig)
if (biactionValue == "ERP Systems") {
def map = ["Cognos","Dynamics AX"]
def optionsMap = options.findAll {
it.value in map
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
bitype.setFieldOptions(optionsMap)
}
else if (biactionValue == "CRM Systems") {
def map = ["MAS 500"]
def optionsMap = options.findAll {
it.value in map
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
bitype.setFieldOptions(optionsMap)
}
else {
bitype.setFieldOptions(options)
}