Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to write validation for a particular field value change

I want to throw an error message on the screen on the change of a checkbox field. SO initially we are writing a JQL query to fetch the results and if results are greater than 1, and if user is trying to check a checkbox field..I should be throwing error.

We have used JWT validators for JQL query but it is stopping us from updating any field on the screen.

SO is there any way to restrict error message only a particular field

2 answers

1 accepted

0 votes
Answer accepted

With Scriptrunner behavior, you can display a red error message just below the checkbox field as soon as the checkbox is clicked.

The tricky thing may be to decide how this script should behave (if at all) when an issue where it was previously checked is opened and the JQL query results now have a value.

If you only need this to run upon issue creation it is simple:

//only run on create (issue doesn't yet exist in the db)
def chkFld = getFieldById(getFieldChanged())
//normalize the checkbox value... behavior returns astring when single box is checked or array when you have more than 1
def checkBoxValue = (chkFld.value instanceof String) ? [chkFld.value] : chkFld.value
chkFld.clearError() //("Security was NOT checked")
if(checkBoxValue.any{it == 'LabelOfYourCheckbox'}){
//do your JQL search here
def resultCount = 1
chkFld.setError("JQL returned more than 1 result")

Hi everyone,

just adding the solution we came up with in the support ticket here in case someone else having a similar question.

The scenario of interest describes as follows: when selecting the option Yes on a select custom field Final Review, check whether there already are other issues with that option. If so, block the transition, if not, pass.

We were finally able to do so given the following expression:

%{15562} = "Yes" IMPLIES count(issuesFromJQL("project = 'SW Build Project' AND issuetype = 'Internal Build' AND 'Final Build' = 'Yes' AND 'Target SW Release' = '" + %{15484} + "' AND key != '" + %{00015} + "'")) = 0

The first part is the initial check of the Final Review field which means, the expression is always true, when the selected option is not Yes.

%{15562} = "Yes" 

The second clause states that if the option Yes is selected, the given query must return 0 results, meaning there must be no other issue with this option.


Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

320 views 0 10
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you