Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,158
Community Members
 
Community Events
176
Community Groups

behavior to show only certain Insight custom field option

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)
}

 

 

1 answer

1 accepted

1 vote
Answer accepted

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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events