Cross field validation - on transition checking the value of one field against another

Hi, I'm currently trying to implement some validation in my Jira workflow to validate that on a transition a field value is checked against another field. Both these fields can be edited on the transition.

I've tried using the "Script Validator" to do this however with no success. my example validator script is something like this:

cfValues['Reapply Needed?'] == 'No' && cfValues['Repository'] != 'trunk'

however you have to link this to a field for the error to be displayed and it seems that when Jira runs this validation it runs it against the current (edited) value of the main field you have assigned it to but against the stored value of the other field.I actually need it to validate the two fields based on the their (unsaved) edited values in the screen when the user makes the transition.

Does anybody have any ideas on how I can do this?

3 answers

1 accepted

1 votes

No, it evaluates it on the edited values of all fields.

You don't need to specify a field, if you leave the field blank the error message will go at the top, but selecting the field only determines where the error message if any is shown, nothing else.

I think the problem is the fields are probably select lists or radio buttons, in which case you need:

cfValues['Reapply Needed?']?.value

same for the other one.

0 votes

please use the right tags (I did it) or you won't get answers.

Jamie, thanks very much for your response, It got me straight to the right answer. For anyone that has similar script issues, here is some of what I have learnt:

If you have a select list and the default value is 'None' then this in script terms is actually null.

e.g: cfValues['selectlist1']?.value != null

If you have a free text field then an empty field is null

As Jamie said above, to check the value of a select field then

cfValues['select list1']?.value == 'blah'

is what you need

Thanks

That's all true, but your first example can be replaced with the following for simplicity (groovy truth):

cfValues['selectlist1']?.value

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,042 views 13 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot