How to make field required on issue creation based on the multiple choice of another field by Script

Julia Petrova February 12, 2025

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!

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events