Forums

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

Jira workflow validator

Kha Hoang July 20, 2023

How do I use workflow validator to either write JQL or scriptRunner code to check for the following:

Only allow transition if:

if (custom_field1 == 'No' || (custom_field1 == 'yes' && custom_field2 != "")

give the popup warning if it doesn't meet the criteria above?

Thank you.

2 answers

1 accepted

1 vote
Answer accepted
Kha Hoang July 24, 2023

I think I figured it out and put it here in case someone will need it later:
cfValues['PR Required']?.getValue() == 'No' || (cfValues['PR Required']?.getValue() == 'Yes' && cfValues['Peer Reviewer(s)'] != null)

0 votes
Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2023

Hi @Kha Hoang 
Go to you workflow, find the transition, go to validators, take the sciptrunner simple scripted validator.  Put your string above in 
custom_field1 == 'No' || (custom_field1 == 'yes' && custom_field2 != "null"

Kha Hoang July 20, 2023

Hi Craig, 

Yes, it sounds very simple but that's what I did but the problem is that regardless I set field1 to Yes or No, it didn't let the issue transition forward to the next status.  It means this condition somehow always false.

The actual code is this:

cfValues['PR Required'] == 'No' || (cfValues['PR Required'] == 'Yes' && cfValues['Peer Reviewer(s)'] != "null")

Thank you.

Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2023

what are the field types?

Kha Hoang July 20, 2023

the PR Required is Option (Yes and No and default is None
The PR Reviewer(s), is a multi-user select field.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.7.0
TAGS
AUG Leaders

Atlassian Community Events