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

JIRA Script Runner Groovy cascade custom field get parent options by index or child options by index



I need some help in Custom Cascade Field, 

 I have created a Cascade Custom Field with

  • parent options = 'Jan-19' , 'Feb-19', 'Mar-19'
  • child options = '0%', '25%', '50%', '75%', '100%'

I know that for parent option, 'None' is one of the options.

I know how to get the value of selected parent option like 

Map p1m0 = getCustomFieldValue("MyCustomFieldName") as Map

monthName = p1m0.get(null)

But how do I get all options of parent select list by their index like index0=None, index1='Jan-19', index2='Feb-19' ...

Even if user selects None, I have to return an indexed parent option to another calculated field based on which month we are in

Similarly how do I get all child options of this cascade custom field and access them by their index. I went through multiple posts but could get this through

Thank you in advance

with warm regards



2 answers

1 accepted

0 votes
Answer accepted

Hello ramki,

Below is the code to get root (parent) options for a cascaded custom field.

import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.option.Options

def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
// change xxxx with id of your cascaded custom field
def cascSelectCf = customFieldManager.getCustomFieldObject("customfield_xxxxx")
// get an issue just for relevant config
def issue = issueManager.getIssueObject("XYZ-123")
Options options = optionsManager.getOptions(cascSelectCf.getRelevantConfig(issue));
def rootOptions = options.getRootOptions()

rootOptions.each { "$it.optionId - $it.value"

Hope it helps

Excellent, thank you Tuncay Senturk,

With your help, in addition to your code, I also found the way to get the Child options

String childOptions = ""
rootOptions.eachWithIndex {it,index->
if(index == 0) {
it.getChildOptions().each {
childOptions += "$it.value"+","
//to remove the last comma in childOptions string
//be aware, there was a space after comma above and I wasted time :)
childOptions = childOptions[0..-2]
monthName = "$it.value"

In addition, if you want the custom field object by name

//def cascSelectCf = customFieldManager.getCustomFieldObject("customfield_14510")
def cascSelectCf = customFieldManager.getCustomFieldObjectByName("MyCustomFieldName")

Also, you can use below code instead of adding/removing "," characters

it.getChildOptions().collect {"${it.value}"}.join(",")


While looking for solutions to my problem I came across your post.

Please help me solve my problem, because I do not master groovy scripts :

Indeed on my cascading custom field, I want to purge the selection list of child options when creating the issue (transition "to create") .


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

112 views 1 2
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