Jira Automation: Wait for IF/ELSE to run before continuing rest of flow?
Asked by Paulo Sebasti?o:

Hi team,  

I'm having a problem which after some googling and some chatGPT I still can't seem to have a clear answer upon.

It seems like there's no sequential guarantee that things will run in order once you have an if/else component in a JIRA automation. Is that correct? See the example below:

![Untitled 2.png](https://community.atlassian.com/t5/image/serverpage/image-id/336752i40E6AF5890AB6A3F/image-size/large?v=v2&px=999 "Untitled 2.png")

Even the "swimlanes" seem to indicate that the start of an IF/ELSE is a fork from the main path and that the main will continue to execute. Is there a way to bring it back to the path? Like, execute everything first in the if/else and only then continue to run the rest of the block?


Answers:
author: Bill Sheboy
body: Hi [@Paulo Sebasti?o](/t5/user/viewprofilepage/user-id/5545260) -- Welcome to the Atlassian Community!

What observations lead you to believe the if / else block is not running sequentially?

My understanding is if / else blocks process sequentially. Based on the rule you show, perhaps one or more of those many Send Web Request actions have not selected the option to "Delay execution of subsequent rule actions..." and so they show in the log as having finished later.

Otherwise, I think only branches which could be on more-than-one-thing run in parallel / asynchronously.

The "swimlanes" you describe are just the recently updated rule editor design, indenting conditional and branching logic visually.

Kind regards,  
Bill

comments: author: Paulo Sebasti?o
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)   

Nice to hear from you, who previously saved me in so many other situations when I read your replies to others :)  

What is leading me to think is not running sequentially is that the log action don't show in correct order in the audit log? I.e. a log action after the branch can occur before all the other actions in the branch have ran - and yes, I've confirmed that the send web requests are "waiting" for the reply.


author: Bill Sheboy
body: Paulo, to confirm the situation: is there a **branch** in your rule or do you mean the **if / else block**?

* If it is a branch, I would expect that behavior for branches which could be on more than one thing
* If it is a single issue branch (e.g., Current Issue) nested within an if / else block, there is an open defect for the symptom of apparent step (or log entry) ordering: <https://jira.atlassian.com/browse/AUTO-1092>

Otherwise...I have observed cases where things in the audit log may appear out of order because they happen in very close time proximity. I have not been able to consistently repro this or I would submit a defect.


author: Trudy Claspill
body: Hello [@Paulo Sebasti?o](/t5/user/viewprofilepage/user-id/5545260)

Welcome to the Atlassian community.

I have seen [suggestions](https://community.atlassian.com/t5/Jira-questions/Split-an-automation-rule-in-multiple-parts-and-run-the-whole/qaq-p/2732484) that you could separate the branch (If/Else) into a separate rule. And in the current rule use a Send Web Request action to call that separate rule rather than having the If/Else directly in this rule.

comments: author: Paulo Sebasti?o
body: This is actually a good practice, maybe only handle failure scenarios on the main rule itself, and then create other rules that are triggered either by calling them or by actions (created branch or pull request, for example) which are output of the main rule. I might look into this.


author: Scott Schellhardt
body: Hi Paulo  

I would break this into multiple rules and have the second rule running based on the conditions defined as part of the completion of the first rule. So basically, from compare two values down, I would make into a separate rule.   

There maybe someone here that has more experience with this type of automation, and can give a better answer but i hope this helps.


Tags: automation

cloud

jira-automation

jira-cloud