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
  • Community
  • Products
  • Jira
  • Questions
  • how to fill the values from 2 - Select List (single choice) custom fields to a Select List (cascading) custom field using script runner

how to fill the values from 2 - Select List (single choice) custom fields to a Select List (cascading) custom field using script runner


I have 2 - Select List (single choice) custom fields i,e 'Server component' & 'subsystem' has several values configured in it. And there is a mapping from one Server component to related multiple subsystem values using these 2 custom fields. 

But I would like to copy these values along with mapping into to a Select List (cascading) custom field i,e Impacted server component-sub-system1 using script runner.

Please suggest how to do this configuration in JIRA version (6.7.16) and script runner for JIRA version ( used in my project.

Otherwise copying these values from 'Server component' & 'subsystem' Select List (single choice)  along with the configured mapping into Select List (cascading) custom field manually is very tedious as we have lot of values configured. Please advice how to do it using script runner, groovy script etc.

4 answers

Hi Manju,

Did you check the Bulk Import Custom Field Values ? I think this is what you need, in order to actually copy custom field values and not just set available options of a select list (using behaviours).

Now what will make your life easier is to get all the values from a script. So, if the configuration Scheme for SelectListA is Global then the following script will give you all the options of the select list A (one every line)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.context.IssueContext

def selectListAConfig = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("SelectListA").getRelevantConfig(IssueContext.GLOBAL)
def selectListAOptions = ComponentAccessor.getOptionsManager().getOptions(selectListAConfig)?.collect {it.value}?.join("<br>")
return selectListAOptions

Now you will do the same for the other custom field. I am not really sure how do you know which one is going to be the parent and which will be the child though. 

regards, Thanos

Thank you very much Thanos for sharing your suggestion, it's really useful.

Let me try this and confirm on the same.

Hi Thanos,
I gone through the "Bulk Import Custom Field Values" SR documentation shared and also your script.
I have a list of values (Server Component to Subsystem values) mapped in Add-ons->Behaviours->"Subsystem" custom field Validation Script. Using this script I can get the Dummy CSV with these values updated for cascading list type as below:

Bulk Import Custom Field Values::


But importing this Dummy CSV into my specific JIRA project and creating so many issues and deleting those issues created with this sample CSV - is this only a feasible option?

OR we can do some other best method to copy these values into my newly added cascading Select list custom fields?? Please advice. 

Hi Thanos,

I got the answers which I posted for the clarifications by your suggestions/inputs shared it before.

I am able to execute the script shared by you in Script Console and able to get the output/values of both Select List (single choice) custom fields.

But I need to manually do the below kind of indentation, 


and Do "Bulk Import Custom Field Values" into cascading list custom fields one by one.

If there any way to write one server side Add-ons->Behaviours-> script and copy the 2 Select List (single choice) custom field values dynamically into a Select List (cascading) custom field i,e Impacted server component-sub-system1 using script runner. As these Select List (single choice) custom field values will get added release on release in our project.


Eagle apk I'm New Here Apr 24, 2021

Have you got a draft dedicated message stored that you use for your commit messages? If so, should you allow us to recognize what's in it? (We've had a crash record that is pretty an awful lot exactly similar to this one on housener

0 votes
Eagle apk I'm New Here May 03, 2021

Have you got a draft dedicated message stored that you use for your commit messages? If so, should you allow us to recognize what's in it? (We've had a crash record that is pretty an awful lot exactly similar to this one on parentner

Have you got a draft dedicate message stored that you use for your commit messages? If so, should you allow us to recognize what's in it? (We've had a crash record that is pretty an awful lot exactly similar to this one on this website.

Hi Manjunatha,

you can use behaviour to reflect the value of one select list to other select list.Please check the following code for reference and make the changes according to your need

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours

def dropdown = getFieldById(getFieldChanged())
def myValue = dropdown.getValue()

//FormField dropdown = getFieldByName("My first value")

FormField other= getFieldByName("Sub-Category")
log.error("---------------- test---------------"+dropdown.getFormValue())
log.error("---------------- secound---------------"+other.getFormValue())

if (myValue == "CEPC")
other.setFieldOptions(["10366"]:"Electronics",["10367"]:"Wireless",["10368"]:"PC",["10369"]:"Office Products",["10370"]:"Musical Instruments",["10371"]:"Headphone",["10530"]:"Speakers",["10531"]:"Camera",["10532"]:"TV",["10533"]:"IT Accessories",["10534"]:"Camera Accessories",["10535"]:"MP3 Player",["10536"]:"memory card",["10537"]:"Projector",["10538"]:"Other Electronics",["10539"]:"Car Electronics",["10540"]:"Blu Ray",["10541"]:"Components",["10542"]:"Power Bank",["10543"]:"Hard Drives - Internal",["10544"]:"Pen Drive",["10545"]:"Hard Drives - External",["10546"]:"Ink Cartridge",["10547"]:"Laptops",["10548"]:"Office Product",["10549"]:"Mobile Accessories",["10550"]:"Solid State Drive",["10551"]:"Media Player",["10552"]:"Phone",["10553"]:"Monitors",["10554"]:"Tablet",["10555"]:"Networking",["10556"]:"Security & Surveillance",["10557"]:"Printer",["10558"]:"Connected Wearables",["10559"]:"Desktop",["10616"]:"Others")
if(myValue == "Consumables")
other.setFieldOptions(["10561"]:"Toys",["10562"]:"Baby Products",["10563"]:"HPC",["10564"]:"Beauty",["10565"]:"Pet Products",["10566"]:"Grocery",["10567"]:"Personal Care Applicances",["10568"]:"Luxury Beauty",["10569"]:"Pantry",["10570"]:"Health & Personal Care",["10616"]:"Others")
if(myValue == "Media")
other.setFieldOptions(["10571"]:"Books",["10572"]:"Music",["10573"]:"Video Games",["10574"]:"Software",["10575"]:"DVD",["10576"]:"DVD Player",["10577"]:"video_games",["10578"]:"digital_text",["10579"]:"digital_accessories",["10616"]:"Others")
if(myValue == "OHL")
other.setFieldOptions(["10580"]:"BISS",["10581"]:"Kitchen",["10584"]:"Furniture",["10586"]:"Sports",["10595"]:"Home",["10598"]:"Automotive",["10599"]:"Major Appliances",["10616"]:"Others")
if(myValue == "Softlines")


Thanks for your prompt response Mayur.

I think from the script posted, we can map one Select List (single choice) custom field values with another Select List (single choice) custom field values. But here I have a Select List (cascading) custom field. and would like to map Select List (single choice) custom field i,e 'Server component' values to first value/first1 and Select List (single choice) custom field i,e 'subsystem' values to second value/second1 with appropriate mapping already done between Server component to subsystem field values as part of the Server component custom field behaviour using the below posted Validation Script.


//server component- subsystem

import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
FormField formComponent = getFieldById(fieldChanged)

FormField formSubcomponent1 = getFieldByName ("Subsystem")
def actionName = getActionName()
def actionId = getAction().getId()
def componentFormValue = formComponent.getFormValue()

Map field1Options = [:]
field1Options.put ("-1", "None")

if((actionId == 1101 && actionName == "Restricted Update")|| (actionId == 1081 && actionName == "Restricted create"))
 switch (componentFormValue) {
  case "10008" : //BANPlatform
   field1Options.putAll (["10320":"Generic",
                          "10650":"User Documentation"
case "10009" : //MS platform
   field1Options.putAll (["10320":"Generic",
 case "-1" :
   field1Options.put ("-1", "None")
  }//switch end
 formSubcomponent1.setFieldOptions (field1Options)

}//if end


Now similarly I need to write a Validation Script for my new custom field i,e i,e Impacted server component-sub-system1 of type Select List (cascading) by mapping to first1 (should be mapped to 'server component' values) and second1 (should be mapped to 'Subsystem' values) options respectively.

def cascade1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Impacted server component-sub-system1")

Map cfVal1 = issue.getCustomFieldValue(cascade1) as Map
first1 = cfVal1.get(null)
second1 = cfVal1.get("1")}

I need suggestion/inputs on how to achieve this???

Suggest an answer

Log in or Sign up to answer

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