Forums

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

Script runner field validator

Gunawan Kosasih
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!
February 26, 2025

Hi everyone,

I'm working with ScriptRunner Behaviors in Jira Cloud and need help implementing a field dependency. Specifically, I want to make the 'App Version IOS' field mandatory when the 'Platform' field is set to 'IOS', and make the 'App Version Android' field mandatory when the 'Platform' field is set to 'Android'.

I've tried using the following Groovy script within a Behavior's validator:

Screenshot 2025-02-27 at 10.01.02.png

 

 

However, I'm encountering a few questions:

  1. Is this the most efficient and correct way to implement this logic in Jira Cloud using ScriptRunner Behaviors?
  2. Are there any potential edge cases or issues I should be aware of?
  3. Are there any alternative approaches (e.g., using workflow validators) that might be more suitable?
  4. Are there any performance consideration to be aware of?

Any guidance or examples would be greatly appreciated!

Thanks in advance

1 answer

2 votes
Kristian Walker _Adaptavist_
Community Champion
February 27, 2025

Hi Gunawan,

I can confirm that behaviours would be the correct approach if you wanted to make fields required on screens.

If you used workflow validators you could this during transitions and pop up transition screens but not do dynamic field level control on screens like you can achieve with behaviours. 

However, in Jira Cloud, behaviours are slightly different as they are written in JavaScript and not in Groovy like on the on-premise versions, which your screenshot shows.

Please note behaviours do not support all project types or field types in Jira Cloud currently and you can see what project types and fields are supported in the documentation page located here.

Also, you can see examples of behaviours scripts in Jira cloud in the page here and the examples below will be a good reference to help you to create the script that you require.

I hope this information helps.

regards,

Kristian

Gunawan Kosasih
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!
February 27, 2025

Hi Kristian,

Thank you for responding my concern, following your writing above, how to confirm which Jira services that my company are using ? I've read in some blog it says when the domain is https://company.attlassian.net then this indicate it is a Jira Cloud that is why I was using Groovy instead of Javascript. 

Also, because my code is not working in Script Runner keep getting bugs and though bugs is solved but unable to save to it in Script Runner, I decided to put the code in Jira Workflow instead of Behaviour in Run Script, this also not achieving the goal of "making a field required". 

Releted to this, what is the difference between Jira Workflow and Script Runner if within Jira Workflow I can also add Script Runner in Worklfow Validator

Regards,

Gunawan

Kristian Walker _Adaptavist_
Community Champion
February 28, 2025

Hi Gushwan,

You are correct that when it is .atlassian.net domain that it is Jira Cloud.

However, in Jira Cloud behaviours use Javascript as documented here which means you wlll need to write it similar to the example I shared.

As mentioned in my previous post, if you use a workflow, it will only work when an issue is transitioned, and Workflow Validators will only apply during a transition.

Behaviours will apply on issue screens such as the create screen, view issue screen or transition screen and that is the difference.

If you need further assistance writing your behaviours script, then please raise a support ticket here, so that our support team can assist with this. 

Regards,

Kristian

Suggest an answer

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

Atlassian Community Events