How to prevent an issue from transitioning in the workflow based on custom field and status?

Henderson_ Michael
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!
March 30, 2024

Hello Atlassian Community! 

I'm a beginner in Groovy Scripting with no previous coding experience and need some help to accomplish the following: 

Goal: 

Create a workflow validator that will prevent an issue from transitioning into the "Done" status if custom field option = "Yes" AND the status of the issue != "In QA"

Here is what I've got so far, but it is not achieving the desired behavior.  After applying this script, all issues are still able to be transitioned to the "Done" status regardless of whether or not the custom field is set to "Yes" or if the status != "In QA"

issue.get("QA Required?") == "No"||(issue.get("QA Required?") == "Yes" && issue.get("Status")!="In QA")

Any help would be greatly appreciated!

2 answers

1 vote
Suprija Sirikonda _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 9, 2024

Hi @Henderson_ Michael,

Your requirement can be achieved using the Jira Misc Workflow Extensions (JMWE) app. 

Solution:

  1. On the transition to "Done" status, add the "Build-your-own Validator" from JMWE.
  2. Select "Choose type" as "Groovy Script"
  3. Add the below Groovy script that returns false when “QA Required?” is “Yes” and status is not “In QA” ; hence prevents the ticket from transitioning. It returns true in all other cases: 
!(issue.get("QA Required?") == "Yes" && issue.get("Status") !="In QA")

I hope this helps! 

BTW, I'm from Appfire, the vendor of JMWE app. 

Regards,

Suprija | Appfire

1 vote
Mirek
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 30, 2024

Welcome @Henderson_ Michael !

I think you can achieve this OOTB by using a workflow condition (I guess it should be "Value Field") on a specific workflow transition that you would like to hide until there is a specific value set. 

This would hide the transition button on the UI of course. 

Read more about what you can do when configuring workflows here

https://support.atlassian.com/jira-cloud-administration/docs/configure-advanced-issue-workflows/

 

Suggest an answer

Log in or Sign up to answer