We have 2 custom field single select, Want to convert those fields as cascaded with script or any other option except default cascaded fields option.
Does any one have idea on this?
Thanks for Support!!!
Thanks,
Rajesh
Hi @Rajesh Kumar ,
Welcome to Atlassian community !!
Unfortunately it is not possible Jira out of the box. But you can achieve it using Script runner Bahaviours:
https://marketplace.atlassian.com/apps/1228522/behaviours-scriptrunner-for-jira-cloud?tab=overview&hosting=cloud
Here is the sample script, considering two select list:
Replace correct field id customfield_XXX1, customfield_XXX2 in code:
import com.atlassian.jira.project.Projectimport com.atlassian.jira.security.roles.*import com.onresolve.jira.groovy.user.FieldBehavioursimport com.atlassian.jira.issue.customfields.option.Optionimport com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def firstField = getFieldById("customfield_XXX1")def firstFieldSelectedValues = firstField.value as List
def secondField = getFieldById("customfield_XXX2")HashSet<String> selectedOptions=new HashSet();
for (option in firstFieldSelectedValues) {def optionName = option.toString();
if(optionName.trim().equalsIgnoreCase("A")){selectedOptions.addAll(new HashSet<String>(Arrays.asList("A1", "A2", "A3")));}if(optionName.trim().equalsIgnoreCase("B")){selectedOptions.addAll(new HashSet<String>(Arrays.asList("B1", "B2", "B3")));}if(optionName.trim().equalsIgnoreCase("C")){selectedOptions.addAll(new HashSet<String>(Arrays.asList("C1", "C2")));}}if (firstFieldSelectedValues != [null] && selectedOptions.size() > 0) {secondField.setFieldOptions(selectedOptions)}
Hope this helps !!
Hi Deepak,
Thanks for the reply
I have used your script and changed the field ids as per my requirement.
Added behavior and selected first field for mapping tried to excecute the same.
But after clicking 'Add' it wont allowing me to move forward.
Kindly help us.
Thanks
It looks like you're new here. Sign in or register to get started.