Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Published in Trello

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

106 views 1 11
Read article

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