I'm trying to add a Behaviour by ScriptRunner to make a field required if in another field multiple values are selected. But it seems the code I created is not working for checkbox field.
For example, I have follwoing fields:
"Field1" - text field type
"Field2" - checkbox field type with a following values: 1, 2, 3, 4
And on issue creation I need "Field1" be required only if 1 and/or 2 values are selected in the "Field2".
Code example I used:
const field1 = getFieldById("field1id");
const changedField = getChangeField();
if(changedField.getName() == "field2" && changedField.getValue().value.contains("1", "2")) {
field1.setRequired(true);
}
In Behaviour: Event is "On change" and View is "Create View".
But it doesn't work at all. I've tried different options for getting values from the "field2" change, but failed in this. What am I doing wrong?
I found a few solutions for the same requests in community but they were for Jira Server, while I'm using Jira Cloud and those solutions didn't help.
Thanks in advance!