Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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
Tuncay Senturk Community Leader Jan 23, 2019

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")
Tuncay Senturk Community Leader Jan 24, 2019

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

Atlassian Community Events