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

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
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

78 views 1 6
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