Scheduled Automation rule with IF ELSE Block Condition not working as expected in Jira

Still need help?

The Atlassian Community is here for you.

Ask the community

robotsnoindex

  

Platform Notice: Cloud, Server, and Data Center - This article applies equally to all 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.


Environment

All versions of Automation for Jira, both for Server/DC and Cloud.


Diagnosis

The Automation rule has a Scheduled trigger (with JQL) and at least one IF / ELSE block, for example:

IF (condition A)
  THEN action A
ELSE
  THEN action B

Or:

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 — opposite to iterating over each issue individually.

So, for a set of 10 issues if "condition A" results in non-empty, 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 non-empty, "action B"is performed and the whole Block is done.

This may be counter-intuitive 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 the open improvement below to add this caveat to the documentation:

JIRAAUTOSERVER-209 - Getting issue details... STATUS


Solution

One alternative is to use several IF / ELSE block separated from each other:

IF (condition A)
  THEN action A

IF (condition B)
  THEN action B

IF (condition C)
  THEN action C

IF (condition "not A and not B and not C")
  THEN action D

The last "else" condition may be tricky as it would need to negate all other conditions in one.

Also, the conditions should be mutually exclusive, or else they need to negate the previous ones:

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

Visual example:


Last modified on May 23, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.