Hi Community!
I'd like to share with you all this recent KB article we published on Automation's IF / ELSE Block Condition:
The diagnosis is simple yet can drive one mad 🤯:
If you've checked ✅ for all three items above, you may be expecting the IF / ELSE to work as we're used in programming languages — but the scheduled JQL trigger has some unique perks...
Take this example:
IF (condition A)
THEN action A
ELSE IF (condition B)
THEN action B
ELSE IF (condition C)
THEN action C
ELSE
THEN action D
Say our trigger JQL fetches 10 issues: 3 meet condition A, 2 meet condition B, 4 met condition C and 1 meet none.
You may expect that with a single execution, 3 issues have action A applied, 2 have action B, 4 have action C and 1 has action D, but what happens is that 3 issues will have action A applied.
And that's it!On a second execution, if there are no issues that meet condition A, then it goes to the ELSE and applies action B to 2 issues.
On the third execution, supposing no new issues meet condition A or B, it applies action C to the 4 issues, and so on.
What happens is that the IF / ELSE is applied to the whole set of issues that the trigger JQL fetched. If a condition is non-empty, Automation goes through that path and, thus, not the others.
😉
We opened JIRAAUTOSERVER-209 to try and make the documentation a bit clearer on this.
So if you want all 4 conditions to be applied in the same Automation rule, you may do something like this (just an example) using the same IF / ELSE Blocks but without using the ELSE, just adding several IFs branching to each action:
IF (condition A)
THEN action A
IF (condition B and not A)
THEN action B
IF (condition C and not A and not B)
THEN action C
IF (condition "not A and not B and not C")
THEN action D
Try it out! See if it works for you!
Happy Jiraing! 😎
Rodrigo Martinez
Premier Support Engineer (Jira DC)
Atlassian
São Paulo, Brazil
1 accepted answer
12 comments