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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

Copying parent and child parts of cascading select custom field to 2 separate custom fields

Hi all,

I have a cascading custom field and 2 separate single select custom fields. I want to copy the parent part of the cascading cf to 1 separate single select custom field and copy the child part of the cascading cf to the other single select custom field. 

Copying the child part works correct via the JSU post function "Copy value from other field"

Copying the parent part I didn't find a solution yet. Who can help me? I am not experienced in Scriptrunner coding, I could use your help there.

Thank you and kind regards, Sandra

2 answers

1 accepted

2 votes
Answer accepted


Let's assume you have a cascading field with values:

a - 1, 2

b - 3, 4

c - 5,6

And two single select list customfields with values:

a, b, c,


In this scenario you can use below script to set single select lists based on the cascading field values:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.customfields.manager.OptionsManager

def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("DSP-4")
def userManager = ComponentAccessor.getUserManager()
def authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def user = authenticationContext.getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def cascading = customFieldManager.getCustomFieldObject("customfield_11303")
def cascadingLevel1 = customFieldManager.getCustomFieldObject("customfield_11304")
def cascadingLevel2 = customFieldManager.getCustomFieldObject("customfield_11305")

def cascadingValue = cascading.getValue(issue)
def cascadingLevel1toSet = cascadingValue[null]
def cascadingLevel2toSet = cascadingValue["1"]

def option1 = optionsManager.findByOptionValue(cascadingLevel1toSet.toString())
def option2 = optionsManager.findByOptionValue(cascadingLevel2toSet.toString())

issue.setCustomFieldValue(cascadingLevel1, option1[0]);
issue.setCustomFieldValue(cascadingLevel2, option2[0]);

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

You can test it on script console. You need to change the issue key to test and customfield ids.


Hi @Elifcan Cakmak , Thank you for you quick and extensive reply. How do I know the custom field ID of the parent part and of the child part? I know how to see the custom field ID of the complete field (via "edit" and check the number in the URL). 

And do I put this piece of coding in a scriptrunner post function in the workflow?

Thank you and kind regards.

Hello @Sandra Meessen  

You don't need id for parent and child. What you use here is the id of customfields. What you are referring to as parent and child are the options(values) of the cascading custom field. See this part:

def cascading = customFieldManager.getCustomFieldObject("customfield_11303")
def cascadingLevel1 = customFieldManager.getCustomFieldObject("customfield_11304")
def cascadingLevel2 = customFieldManager.getCustomFieldObject("customfield_11305")

cascading: change it to your cascading custom field's id

cascadingLevel1: change it to your single select list custom field id that you want to copy the parent part of the cascading field

cascadingLevel2: change it to your single select list custom field id that you want to copy the child part of the cascading field

See example screenshot below:


You need to remember that your single select list custom field should contain the values that will come from the cascading field as I explained above.

After you test it on script console, you can put it on the post function as you stated. But you need to remove this part when you put it there:

def issue = issueManager.getIssueObject("DSP-4")

This part is to test the code with a specific issue. When you remove it, script will get the issue itself during transition.

Hope this makes sense.


Hi @Elifcan Cakmak , thank you for your clear explanation, I am trying this in our Script Console, but I get this error message. What am I doing wrong? Thank you and regards, Sandra Screenprint Script console.png

Hello @Sandra Meessen  

I am getting the same error (static type checking) on script console, it does not prevent the script working. However the below error on the result is different. Can you try to return option 1 with

return option1

 Here is my screenshot. See below option1 returns as a list [b, b]. That's why we are using option1[0] below while setting the custom field value. 


Hello @Elifcan Cakmak 

Thanks for helping with this script.  Could you please help me understand how to modify this script to perform this update on all issues within a single project at once?  I want to run this through the console.



Hello Everyone,

I have used above script to copy field values from cascading field but I need to update the "Issue Key" automatically, is there any possibilities for this action?

It would be helpful for us.

Thanks in Advanced.



@Elifcan Cakmak @Kevin Carroll @Sandra Meessen 

Can you please look into the above issue.

Hi @Elifcan Cakmak ,

Can we copy cascading first filed value to a text box in same issue after creating the issue ?

Cascading filed : X Y Z  X1 X2 X3 Y1 Y2 Y3 Z1 Z2 Z3

I need to copy the values X or Y or Z to text filed Using Post function script 


I have asked a question 



This script does not work on cloud, How to configure the same requirement in JIRA cloud.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events