Hi,
I'm trying to achieve that a custom field only appears when a multi-select field contains a certain option. For that, I'm using Behaviours in Scriptrunner plugin from Adaptavist.
I have used Behaviours before with a single select and tried using the same groovy script here but it doesn't do what I need. This is the script:
//customfield_12103 = multi-select
//customfield_12100 = checkbox field
//I want the checkbox field to apear only if the multi-select field contains "FreeRounds type" option.
def dropDown = getFieldById("customfield_12103")
def conditionA = getFieldById("customfield_12100")
log.debug("dropdown value" + dropDown.getValue())
if (dropDown.getValue() == "FreeRounds type") {
conditionA.setHidden(false);
conditionA.setRequired(false);
} else {
conditionA.setHidden(true);
conditionA.setRequired(false);
}
What it does, is that if I only select "FreeRounds type" option in my multi-select it works fine and the field of the same name appears:

However as soon as I add another option to this multi-select, the field "FreeRounds type" disappears:

I found that changing == to .contains would work so I changed the line 6 to:
if (dropDown.getValue().contains("FreeRounds type")) {
but that returns an error:

and the Behaviour loses its functionality entirely. The field is never hidden:

I have searched around and couldn't find a working example for my case anywhere. I am no coder, can anyone please help me with this groovy script for multi-select field, please?
We're using:
- Jira Software v8.13.9
- Scriptrunner v6.30.2