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

Taras Gural Apr 20, 2018

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

0 votes
Neta Elyakim Apr 30, 2018 • edited

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Opsgenie

Handling Opsgenie Alerts

Hi everyone, welcome to the kb articles for Opsgenie FAQs. I'm one of the Technical Support Engineers for Opsgenie who will be providing weekly posts on FAQs from customers.   All alerts are ...

66 views 0 3
Read article

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