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)
}
In behaviours, you can read a value or set a value on an Insight Custom Field, but you can't control the look/feel or visible list of results.
Thankfully, Insight custom field provides this functionality out of the box.
Create a new "Select" attribute in your Insight object type with a name like "Type of System" and in there add the options: "ERP Systems" and "CRM Systems".
Then set that attribute accordingly in each of the object.
In the Insight Custom field configuration under "Filter Issue Scope (IQL)" add the criteria
"Type of System" = ${customfield_17401.label}
Then Insight will automatically filter the list of objects according to selected values in your select custom field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.