How do I write a groovy expression for my workflow post-function? (Only run transition when issue priority != "HotFix")

brian steele March 4, 2015

I apologize if this question makes little sense, but I was volunteered to be the JIRA "guy" and I have zero background in programming. 

I have JIRA Misc Workflow extensions installed and I'm trying to use the "Set Field Value to constant or Groovy expression Function" to automatically set the "Priority" of an issue to "InSprint" if it's "Priority" isn't already set to "HotFix" OR "High", when they transition from "ToDo" to "InProgress". 

However, I don't know what to type into the Conditional execution box. It says, "Type a groovy expression that returns true if the post-function should run"

Since I have no idea what I'm doing with Groovy expressions, I'm pretty sure it's my attempt that's gumming up the works. Any help with that would be great. I'm not even sure this is the best way to achieve the results I want so if anybody has a better way, I'd love to know about it. 

This was my last configuration: 

Field: Priority

Value type: Raw Value

Value: InSprint

Conditional execution: selected

  • Execute if the following Groovy expression returns true: 
issue.get("Priority") != "HotFix" || issue.get("Priority") != "High"

 

 

1 answer

0 votes
MikeyS
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.
March 4, 2015

Your statement will always return true.  You'd want something like:

issue.get("Priority") != "HotFix" && issue.get("Priority") != "High"

Which means the priority is neither HotFix nor High, which is what I believe you want.

brian steele March 4, 2015

Thank you for taking the time to respond Mikey. I input your expression using my last configuration and it didn't appear to work as I expected. Maybe a user story with acceptance criteria would better explain my needs. As a JIRA Agile user I want to transition any issue from "Open" status to the "InPogress" status and have JIRA automatically change the issue priority to "inSprint", unless the "Priority" is already set to "Hotfix" or "High", so I don't have to edit the issue manually. AC: # on transition issue priority is changed to "InSprint" if priority IS NOT already set to "HotFix" or "High" # on transition issue priority is NOT changed if priority is already set to "HotFix' or "High"

Suggest an answer

Log in or Sign up to answer