It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using cacading select list in Behaviours

Hi, 

I have a script with which i hide some options from select list, and i wont to do same with cascading select list. I try to do it with this script but it does not works

import com.atlassian.jira.component.ComponentAccessor
def supLine = getFieldByName("cascading select")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = customFieldManager.getCustomFieldObject(supLine.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsMap = options.findAll {
it.value in ["xxx"]
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
def parentOption = options.find {it.value == "xxx"}
def childOption = parentOption?.childOptions?.findAll {it.value in "yyy"
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
supLine.setFieldOptions(childOption)
supLine.setFieldOptions(optionsMap)

1 answer

Try to use HashMap

import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.impl.CascadingSelectCFType

HashMap<String, Option> hashMapEntries = (HashMap<String, Option>) customFieldValue

Option parent = hashMapEntries.get(CascadingSelectCFType.PARENT_KEY)
Option child = hashMapEntries.get(CascadingSelectCFType.CHILD_KEY) 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Portfolio for Jira

Program managers, we need your help! We want to learn about how you plan work for a team of teams

Hi community members, My name is Erika and I’m a product manager at Atlassian. We’re currently investigating how teams are planning work at the program level. We understand that every team in a tea...

116 views 0 5
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