Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create multi-level Cascading Select List with ScriptRunner

jessiexjqin August 31, 2020

Hello There,
I would like to use a multi-level cascading select lists with ScriptRunner.

There's the custom field type "Select List (cascading)" only supports 2 levels, and I want to 3 levels (and maybe more). I search in community that there is an add-on "Multi-Level Cascading Select" can full fill this, but is non-free. Does anyone try with ScriptRunner?

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2020

Have a look through https://library.adaptavist.com/search?page=1&products=jira&term=select - there are loads of scripts there that could help you make fields interdependent.

James Webster
Contributor
November 11, 2021

Hi @jessiexjqin ,

Did you find or create a script for the multi-level (more than the standard 2) cascade?

Thanks,

James 

chinmay borkar January 12, 2022

Hi @jessiexjqin and @James Webster  did you get the solution for this condition.

James Webster
Contributor
February 2, 2022

Hi @chinmay borkar ,

 

I managed to work out a custom script in the end which I set up as a behavior.

 

You need an initialiser first (replace the bits in bold) - 


import com.atlassian.jira.component.ComponentAccessor


def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def customField1 = getFieldByName('******Field name 1******')
def customField1Value = customField1.getValue()

def customField2 = getFieldByName('******Field name 2******')

def CustomField2CF = customFieldManager.getCustomFieldObjectsByName("******Field name 2******")[0]
def config = CustomField2CF.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

switch(customField1Value){

case '****Field 1 drop down value A****':
def newOptions = options.findAll { it.value in ["***Field 2 drop down value A***", "***Field 2 drop down value B***", "***Field 2 drop down value C***"] }
customField2.setFieldOptions(newOptions)
break;

case '****Field 1 drop down value B****':
def newOptions = options.findAll { it.value in ["***Field 2 drop down value D***", "***Field 2 drop down value E***"] }
customField2.setFieldOptions(newOptions)
break;

case '****Field 1 drop down value C****':
def newOptions = options.findAll { it.value in ["***Field 2 drop down value F***", "***Field 2 drop down value G***"] }
customField2.setFieldOptions(newOptions)
break;

}


Then you add the serverside scripts with the Field 1 script the same as above and then the subsequent field scripts updated reference the relevant data sets is -

Field 1 Server-side script covers Fields 1 + Field 2

Field 2 Server-side script covers Fields 2 + Field 3

Field 3 Server-side script covers Fields 2 + Field 4

and so on....

 

Hope that helps...

James

Like # people like this

Suggest an answer

Log in or Sign up to answer