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:
Here is the sample script, considering two select list:
Replace correct field id customfield_XXX1, customfield_XXX2 in code:
import com.atlassian.jira.project.Project
import com.atlassian.jira.security.roles.*
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.issue.customfields.option.Option
import com.onresolve.jira.groovy.user.FieldBehaviours
import 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
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.