Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Q&A
  • Jira
  • Questions
  • Behaviours plugin filter cascading select list values based on project selection on issue creation

Behaviours plugin filter cascading select list values based on project selection on issue creation

Todd Winton
Contributor
November 27, 2015

Using the plugin, I would like to filter the parent values of a cascading select list.  I use the following to filter a single select list and it works fine.  

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def formField = getFieldByName("System") 
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsMap = options.findAll {
    it.value in ["ATLAS Cotton",
"C4",
"LDC Insight",
"LDC CRM",
"LATAM C4",
"LATAM DCentral"] 
}.collectEntries {
    [
        (it.optionId.toString()) : it.value
    ]
}
formField.setFieldOptions(optionsMap)

5 answers

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
December 1, 2015

I think you want to set the values of a cascading select? I think this is still not supported. 

0 votes
Todd Winton
Contributor
November 30, 2015

Jamie, That is correct, how do I filter cascading select using something similar to the above. I only need to filter the parent level selections.

0 votes
Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
November 30, 2015

Hi Todd,

If I understand well, you need to determine if an option in a cascading list is a parent option or not. If that is the case you can use in your's findAll closure

it.getChildOptions()

If the option is a parent option this will return to you it's children, if not then it will return null.

0 votes
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Atlassian Partner
November 27, 2015

I guess the question is how to do the above with a cascading select.

0 votes
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Atlassian Partner
November 27, 2015

What's the question?

Suggest an answer

Log in or Sign up to answer