Order of If statements in automation

Robert Nichols March 14, 2024

I've created complex automation in JSM Cloud that does a task and then has some verification before the next step. Using several If else loops 

So for example 

If X then 
   Create User
else 
   Log Error : X Missing

If User is created then 
   Add User to Organization 
else 
   Log Error : User missing 


However it seems that the second If sometimes runs before the first.
So it  logs User missing, but then creates the user.

I have several of these loops to verify the process have run correctly before the next step
Anyone know a way of ensuring they run is sequence  ?

 

2 answers

1 vote
Bill Sheboy
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.
March 14, 2024

Hi @Robert Nichols 

Short answer: please post images of your complete rule and audit log details showing the rule execution.  Those will help clarify what is happening.

 

More information...

That symptom is quite odd, and possibly from some another cause, based on the rule you describe.  Instead maybe the audit log display order is wrong because the rule steps occur so quickly there is no measurable time difference to order the log.

Unlike branches, I do not believe if / else blocks process asynchronously and in parallel.  That would definitely be in the documentation if it was the case, and otherwise I would expect thousands of customers to see rule timing errors continually.

There is an edge case of this symptom you describe: if there is a branch inside of an if / else block, we should expect no predictable order of steps from inside the branch relative to the rest of the rule.

 

We can confirm this if you please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see that...

Based on the rule you describe, it is unclear to me why you are using two different if / else blocks.  Instead the condition on user created could be immediately after the attempted create action.

Kind regards,
Bill

0 votes
Uday Kiran Bhaviri
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.
March 14, 2024

Can we use refetch component in your automation...

Refetch is something it will wait until the first action completes

https://confluence.atlassian.com/automationkb/usage-of-the-refetch-component-in-an-automation-rule-1277100354.html

The other option is to split the automation in to two or more as per your requirement.

Robert Nichols April 2, 2024

Refetch was a good idea, although I was hitting the function limit so couldn't add a lot of extra refetches

I've now reworked it all to just have it in one main thread. which works but limits the error checking.
If I start getting issues I'll take another look at it  

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events