You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.