I would like to logically link three "multi select list" custom fields with a Script Runner Behavior.
The five custom fields should be structured as follows:
custom Field 1: „1st Level“
Values:
custom Field 2: „2nd Level“
Values:
custom Field 3: „3rd Level“
Values:
As soon as "1" is selected in custom field 1, I would like only the values "1.1 and 1.2" to be displayed in custom field 2. In exactly the same way, only the 1.x selection options should be displayed in the third field. However, if you also select 2 in addition to 1 in custom field 1, everything with 2 should also be displayed in the lower levels.
Thank you :)
Hi @Alpo
For your requirement, you will need to create 2 Server-Side Behaviour configurations.
The first Behaviour configuration will be for the 1st Multi-Select list, which will filter the options of the 2nd Multi-Select List.
The Second Behaviour configuration will be for the 2nd Multi-Select List, which will filter the options of the 3rd Multi-Select List.
Below is a sample working code for the 1st Multi-Select List:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def multiSelect1 = getFieldById(fieldChanged)
def multiSelect1Value = multiSelect1.value.toString()
def multiSelect2 = getFieldByName('Multi Select 2')
def multiSelect2Options = []
if (multiSelect1Value == '[1]') {
multiSelect2Options = ['1.1', '1.2']
} else if (multiSelect1Value == '[2]') {
multiSelect2Options = ['2.1', '2.2']
} else if (multiSelect1Value == '[3]') {
multiSelect2Options = ['3.1', '3.2']
} else if (multiSelect1Value == '[1, 2]') {
multiSelect2Options = ['1.1', '1.2', '2.1', '2.2']
} else if (multiSelect1Value == '[1, 3]') {
multiSelect2Options = ['1.1', '1.2', '3.1', '3.2']
} else if (multiSelect1Value == '[2, 3]') {
multiSelect2Options = ['2.1', '2.2', '3.1', '3.2']
} else {
multiSelect2Options = ['1.1', '1.2', '2.1', '2.2', '3.1', '3.2']
}
multiSelect2.setFieldOptions(multiSelect2Options)
Below is a screenshot for the 1st Multi-Select List's Behaviour configuration:-
Below is a sample working code for the 2nd Multi-Select List:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def multiSelect2 = getFieldById(fieldChanged)
def multiSelect2Value = multiSelect2.value.toString()
def multiSelect3 = getFieldByName('Multi Select 3')
def multiSelect3Options = []
if (multiSelect2Value == '[1.1]') {
multiSelect3Options = ['1.1.1', '1.1.2']
} else if (multiSelect2Value == '[1.2]') {
multiSelect3Options = ['1.2.1', '1.2.2']
} else if (multiSelect2Value == '[2.1]') {
multiSelect3Options = ['2.1.1', '2.1.2']
} else if (multiSelect2Value == '[2.2]') {
multiSelect3Options = ['2.2.1', '2.2.2']
} else if (multiSelect2Value == '[3.1]') {
multiSelect3Options = ['3.1.1', '3.1.2']
} else if (multiSelect2Value == '[3.2]') {
multiSelect3Options = ['3.2.1', '3.2.2']
} else if (multiSelect2Value == '[1.1, 1.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '1.2.1', '1.2.2']
} else if (multiSelect2Value == '[1.1, 2.1]') {
multiSelect3Options = ['1.1.1', '1.1.2', '2.1.1', '2.1.2']
} else if (multiSelect2Value == '[1.1, 2.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '2.2.1', '2.2.2']
} else if (multiSelect2Value == '[1.1, 3.1]') {
multiSelect3Options = ['1.1.1', '1.1.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[1.1, 3.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[1.2, 2.1]') {
multiSelect3Options = ['1.2.1', '1.2.2', '2.1.1', '2.1.2']
} else if (multiSelect2Value == '[1.2, 2.2]') {
multiSelect3Options = ['1.2.1', '1.2.2', '2.2.1', '2.2.2']
} else if (multiSelect2Value == '[1.2, 3.1]') {
multiSelect3Options = ['1.2.1', '1.2.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[1.2, 3.2]') {
multiSelect3Options = ['1.2.1', '1.2.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[2.1, 2.2]') {
multiSelect3Options = ['2.1.1', '2.1.2', '2.2.1', '2.2.2']
} else if (multiSelect2Value == '[2.1, 3.1]') {
multiSelect3Options = ['2.1.1', '2.1.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[2.1, 3.2]') {
multiSelect3Options = ['2.1.1', '2.1.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[2.2, 3.1]') {
multiSelect3Options = ['2.2.1', '2.2.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[2.2, 3.2]') {
multiSelect3Options = ['2.2.1', '2.2.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[3.1, 3.2]') {
multiSelect3Options = ['3.1.1', '3.1.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[1.1, 1.2, 2.1]') {
multiSelect3Options = ['1.1.1', '1.1.2', '1.2.1', '1.2.2', '2.1.1', '2.1.2']
} else if (multiSelect2Value == '[1.1, 1.2, 2.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '1.2.1', '1.2.2', '2.2.1', '2.2.2']
} else if (multiSelect2Value == '[1.1, 1.2, 3.1]') {
multiSelect3Options = ['1.1.1', '1.1.2', '1.2.1', '1.2.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[1.1, 1.2, 3.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '1.2.1', '1.2.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[1.1, 2.1, 2.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '2.1.1', '2.1.2', '2.2.1', '2.2.2']
} else if (multiSelect2Value == '[1.1, 2.1, 3.1]') {
multiSelect3Options = ['1.1.1', '1.1.2', '2.1.1', '2.1.2', '3.1.1', '3.2.2']
} else if (multiSelect2Value == '[1.1, 2.1, 3.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '2.1.1', '2.1.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[1.1, 2.2, 3.1]') {
multiSelect3Options = ['1.1.1', '1.1.2', '2.2.1', '2.2.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[1.1, 2.2, 3.2]') {
multiSelect3Options = ['1.1.1', '1.1.2', '2.2.1', '2.2.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[1.2, 2.1, 2.2]') {
multiSelect3Options = ['1.2.1', '1.2.2', '2.1.1', '2.1.2', '2.2.1', '2.2.2']
} else if (multiSelect2Value == '[1.2, 2.1, 3.1]') {
multiSelect3Options = ['1.2.1', '1.2.2', '2.1.1', '2.1.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[1.2, 2.1, 3.2]') {
multiSelect3Options = ['1.2.1', '1.2.2', '2.1.1', '2.1.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[1.2, 2.2, 3.1]') {
multiSelect3Options = ['1.2.1', '1.2.2', '2.2.1', '2.2.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[1.2, 2.2, 3.2]') {
multiSelect3Options = ['1.2.1', '1.2.2', '2.2.1', '2.2.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[2.1, 2.2, 3.1]') {
multiSelect3Options = ['2.1.1', '2.1.2', '2.2.1', '2.2.2', '3.1.1', '3.1.2']
} else if (multiSelect2Value == '[2.1, 2.2, 3.2]') {
multiSelect3Options = ['2.1.1', '2.1.2', '2.2.1', '2.2.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[2.1, 3.1, 3.2]') {
multiSelect3Options = ['2.1.1', '2.1.2', '3.1.1', '3.1.2', '3.2.1', '3.2.2']
} else if (multiSelect2Value == '[2.2, 3.1, 3.2]') {
multiSelect3Options = ['2.2.1', '2.2.2', '3.1.1', '3.1.2', '3.2.1', '3.2.2']
} else {
multiSelect3Options = ['1.1.1', '1.1.2', '1.2.1', '1.2.2', '2.2.1', '2.2.2', '3.1.1', '3.1.2', '3.2.1', '3.2.2']
}
multiSelect3.setFieldOptions(multiSelect3Options)
Below is a screenshot of the 2nd Multi-Select List's Behaviour configuration:-
Please note that the sample codes above are not 100% exact to your environment. Hence, you will need to make the required modifications.
Also, please note that I have not added all the options for the 2nd Multi-Select List, as there are many to add. I've just added a few to display the functionality. You will need to modify the Behaviour codes according to your requirements.
Below are a couple of test screenshots for your reference:-
1. When an option is select from the Multi Select 1 list as expected, the options in the Multi-Select 2 list are filtered as shown in the screenshot below:-
2. Similarly, when the options are select from the Multi-Select 2 list, as expected the options on the Multi-Select 3 list are filtered as shown in the screenshot below:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
Hi @Alpo
Has your question been answered?
If yes, please accept the solution provided.
Thank you and Kind regards,
Ram
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.