Troubleshoot IF ELSE Block Condition in Scheduled Jira Automation Rules
Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
A scheduled Automation rule with the IF / ELSE Block Condition may require several executions to work as expected.
Diagnosis
The Automation rule has a Scheduled trigger (with JQL) and at least one IF / ELSE block
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
On the first execution of the rule, only action A is performed.
On the second execution of the rule, only action B is performed, or action A is performed again.
On the third execution of the rule, only action C is performed, and so on.
It takes several consecutive executions to execute all actions of the IF / ELSE blocks.
Cause
This is actually the way the IF / ELSE Blocks work in Automation for Jira.
In Scheduled rules, the Conditions are applied to the set of Issues as fetched by the trigger JQL as a whole—the opposite of iterating over each issue individually.
Example
For a set of 10 issues or work items, if condition A results in a non-empty result, then action A is executed, and the IF / ELSE block is done.
If condition A results in an empty result, then if condition B results in a non-empty result, action B is performed and the whole Block is done.
This may be counterintuitive to programmers, who may expect that each action would be applied to the given issues that match the respective conditions:
3 issues updated with action A,
2 issues updated with action B,
4 issues with action C, and so on.
We have an open suggestion to add this caveat to the documentation: JIRAAUTOSERVER-209 - Improve documentation on the IF ELSE condition behavior
Solution
Separate the conditions
Make use of several IF / ELSE blocks separated from each other:
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
⚠️ CAREFUL: Each condition must be mutually exclusive. That means any issue that fulfills condition A must not fulfill any of the other conditions.
Visual example:

Was this helpful?