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,293,410
Community Members
 
Community Events
165
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
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

176 views 0 4
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you