Workflow Condition - Based on the value of a field.

Bill Davis November 18, 2011

i have a business need in my workflow to allow a JIRA to Move from an Awaiting Approval Stage to an Approved Stage using a transition called 'Approve Issue'. But I have a few conditions that need to exist that limits who can see the Approve Issue Transition link.

There are two fields that need to be referenced in this case - Field A and Field B.

When the JIRA is in the Awaiting Approval stage the link will appear for differnt groups depending on the value in Field A:

  • If the value of Field A or Field B are < $1000 then only Group 1 has access to the Transition
  • If the value of Field A or Field B are $1000 to $3000 then only Group 2 has access to the Transition
  • If the value of Field A or Field B are > $3000 then only Group 3 has access to the Transition

i have been trying to figure out how to do this under the one transition and have been trying the Value Field Condition with the User Is In Group Condition, but I'm having troubles getting these rules straight.

Is anybody able to help me build these rules?

2 answers

1 accepted

0 votes
Answer accepted
Marek Soukup November 18, 2011

You have to make the condition in the right order. You have to start with the user is in group conditions and swith to OR. Than "add grouped condition" to each existed condition and than "add grouped condition" to them.

See the picture.

Is this the solution?

Bill Davis November 20, 2011

I understand exactly what you are saying, but I can not get the conditions to be grouped as you have them in the image. I tried multiple times and the conditions keep getting bumped out of the groupings and I end up with a slightly different set of conditions.

Why does JIRA make this so....painful when it's a simple Boolean logic we are attempting?

Marek Soukup November 21, 2011

You have to create the conditions in the right order (from the top to the bottom):

  1. Add new condition, select the user is in group and create the condition to Group 1
  2. Add new condition, select the user is in group and create the condition to Group 2
  3. Switch the operator to OR
  4. Add new condition, select the user is in group and create the condition to Group 3
  5. Add groupped condition on Group 1 condition and create the condition to Field A < $1000
  6. Add groupped condition on Field A condition and create the condition to Field B < $1000
  7. Switch the operator to OR between the Field A and Field B conditions
  8. Add groupped condition on Group 2 condition and create the condition to Field A >= $1000
  9. Add groupped condition on Group 2 condition and create the condition to Field B >= $1000
  10. Switch the operator to OR between the Field A and Field B
  11. Add groupped condition on Field A condition and create the condition to Field A <= $3000
  12. Add groupped condition on Field B condition and create the condition to Field B <= $3000

The last condition is the same as the condition for Group 1. I hope this will work.

Bill Davis November 21, 2011

Thank you so much for giving me that detail, it works perfectly!

1 vote
Radu Dumitriu
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.
November 20, 2011

My 2 cents: For this kind of logic you should use some plugins, because this tends to explode in some hard-to-maintain installation.

with my baby (JJupin), this is only one condition and is written directly as:

return ( (userInGroup("Group 1", currentUser()) and (A < 1000 or B < 1000))

or (userInGroup("Group 3", currentUser()) && (A > 3000 || B > 3000))

or (userInGroup("Group 2", currentUser()) and ((A &gt;= 1000 and A &lt;=3000) or (B &gt;= 1000 and B &lt;= 3000)));

Note: this is untested, and only for illustation purposes; normally these values should be defined as constants somewhere, some checks should be added ....

You can try Jamie's Script Runner (same idea, groovy, free), or any other one that fits to this purpose.

Radu Dumitriu
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.
November 20, 2011

well, code formatting kinda work

Bill Davis November 20, 2011

It's very easy to edit the values within an existing condition, less than 2 minutes, same as it would be to change in a formula that Radu has listed. If I ever get the conditions to line up, they would work, but I can not get them to line up...2 hours in and I'm still trying every method under the book to create this Boolean logic...lol

JamieA
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.
November 20, 2011

When I saw Marek's picture above, I had exactly the same thought as Radu. What if you need to change one of the constant values, eg 3000. Painful.

JamieA
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.
November 20, 2011

In some scripting plugins the logic can be in a file outside the workflow, so you don't even need to create a draft and all that. Plus you could apply the same logic to multiple workflows, and only change the parameters in one place. It's not so much that it's tedious and manual, but also error prone. Given that in the picture above the same value is used about 3 times, and I assume you'd want that to be consistent.

Bill Davis November 20, 2011

Thanks guys, unfortunately, it's not free and I do not have the technical skill set to install or create scripts like this, so I'd prefer to use the base features that come with JIRA or plug-ins that are open.

JamieA
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.
November 20, 2011

I completely understand the sentiment of someone not feeling they have the technical skills to go this route, and your current issue is probably not reason enough to go down that avenue. However most of the scripting plugins (groovy, python) are free and OSS.

Radu Dumitriu
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.
November 20, 2011

Yeap, as both of us suggested, there are free plugins out there. JJupin is not the way to go unless you have a huge WF, with many system interactions (additional databases, other Jira installs, exotic data sources, etc).

Suggest an answer

Log in or Sign up to answer