Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner Behaviors - make field required if value in another field is a certain value

Leigh Crawford
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 26, 2025

All the google and chatgpt in the world is getting me nowhere, so hoping someone here can help!

We are new to behaviors.  

We have two fields; let's call them origin and customer. Both are on the Bug type and select lists. 

If value "external" is selected in origin, we want the customer field to be required. 

We want this to happen if external is chosen on create or edit. 

I have tried so many permutations of the scripts and am not sure which would be closer. I don't see anything in the "Affected field/s" column on my behavior, and not sure how to add that, if that's the problem. 

I'm sure I'm overlooking something simple so appreciate any help. Even the script on the examples didn't work. 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Trudy Claspill
Community Champion
November 26, 2025

Hello @Leigh Crawford 

While I'm working out the solution, can you tell us what is the Type of the project/space this concerns? Get that by clicking the ... next to the project/space name and looking at what appears at the bottom of the pop-up.

Screenshot 2025-11-26 at 2.19.53 PM.png

Trudy Claspill
Community Champion
November 26, 2025

For Company and Team Managed Software and Business Spaces what you want to do is possible only on the Create  and workflow Transition screens. It is not possible to set a Select List field to Required in the View screen.

Refer to

https://docs.adaptavist.com/sr4jc/latest/features/behaviours/behaviours-supported-fields-and-products

 

In the Create screen and in a workflow Transition screen, the script would look like this:

const changedField = getChangeField();

if(changedField.getName() == "origin"

&& changedField.getValue().value == "external") {

getFieldById
("customfield_12345").setRequired(true);

}else{

getFieldById("customfield_12345").setRequired(false);

}

 

customfield_12345 needs to use the ID number of you customer custom field.

One way you can get that id is by going to the Custom Fields administration page, finding the field, and then selecting the Contexts and default values action.

The URL of the new page will have the field ID at the end of it: i.e.

https://yourSite.atlassian.net/secure/admin/ConfigureCustomField!default.jspa?customFieldId=10059

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events