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

Cascade Select List setFieldOptions for children groovy

 

How can I restrict parent *and child values* in a cascading select list using groovy / Script Runner?

 

Set form values is straight forward:

https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/setting-default-fields.html

and I know how to set single select list options:



def customField = customFieldManager.getCustomFieldObjectByName(fieldName)
def fieldConfig = customField.getRelevantConfig(getIssueContext())

def options = optionsManager.getOptions(fieldConfig)

def optionsMap = options.findAll {
it.value in ["TBD"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}


field.setFieldOptions(optionsMap)


What form should the optionsMap take for cascading select list? Map[ OptionsId, {value list}]? 

 

Any help would be hugely appreciated!

 

 

 

1 answer

0 votes

Hi @Carlos David 

I recently answered a similar question few days ago. Take a look here.

You can try something like this.

def parentField = getFieldById("customfield_10802")
def parentFieldValue = parentField.getValue()
def childField = getFieldById("customfield_10802:1")
def childFieldValue = childField.getValue()

Let me know if this works.

Ravi 

Hi Ravi,

I want to set the parent and child options in the cascade select list, not get the values. I don't think this is possible however.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Desk

The Complete Guide to Atlassian for ITSM

Hi Atlassian Community! This is Teresa from the Atlassian team. My colleague Paul Buffington @Buff and I are excited to share a brand new ITSM resource we’ve created – "The Complete Guide to At...

2,211 views 14 22
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