Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

In a for each branch, how do I use IF/ELSE

Manav Shah
Contributor
October 7, 2025

I have 2 issues here:

1. How do I make sure that both the conditions run inside the branch or how do I restructure it?

2. If my lookup has 5 issues, it is creating 5 new tickets, but I want only 1 ticket to be created. this is because it is "for each issue". how do I solve this?

Let me explain my automation flow once: 

Scheduled Trigger
└── Lookup recent issues
    └── For each issue
        ├── Create firmId variable
        ├── Lookup 90-day issues for firmId
        ├── If > 4 issues
            ├── Lookup existing Tickets
            ├── If Ticket already exists for the firmID → Edit and link issues
            └── If not → Create new ticket


So basically, I am running a scheduled JQL trigger, and storing firmID from those tickets. Then I am checking if the firmID is used for more than 4 issues in lookup. 

if it is more than 4, then there are 2 conditions:
if ticket already exist, then link trigger ticket to existing ticket
if ticket doesn't exist, create a new ticket

Screenshot 2025-10-07 174858.png


I have 2 "IF" conditions in a single branch. Once the first "IF" condition fails, the second one is not even checked for. How do I make it to check for both if conditions? 

 

Screenshot 2025-10-07 175119.png

this is the audit log. it exits after if lookup > 0. but my 2nd IF condition is IF lookup = 0. 

 

2 answers

2 votes
Mikael Sandberg
Community Champion
October 7, 2025

What you see is expected, IF conditions are evaluated sequentially the way your rule is currently configured. Currently For each branches don't have access to IF/ELSE conditions, you you would need to reconfigure your automation. One way would be to call a second automation that does the actual work and use the IF/ELSE condition there.

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.
October 7, 2025

Hi @Manav Shah 

Adding to the suggestions from @Mikael Sandberg ...

If / Else Condition blocks cannot be used inside of branches, but branches can be used inside of If / Else blocks.  Perhaps restructuring the rule will help, and...

What problem is your rule trying to solve?  That is, "why do this?"  If you explain your scenario that will help the community suggest alternatives.  Perhaps like this:

GIVEN some initial condition
AND some other initial condition
WHEN I do this thing
THEN perform this action

 

Kind regards,
Bill

Like Mikael Sandberg likes this
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.
October 7, 2025

Thanks for that additional information, @Manav Shah 

You do not show your entire rule, and from what you describe, I wonder if you could use the Scheduled Trigger with JQL to find the "recent issues" rather than a lookup.  Then the trigger would handle the iteration rather than branching.

For example:

  • trigger: scheduled, with JQL for your "recent issues"
  • action: lookup issues, with JQL to identify the "firmId" related ones
  • if / else block
    • now you can test the lookup issues result for each condition...
  • else / if ...

 

Like Mikael Sandberg likes this
Manav Shah
Contributor
October 7, 2025
0 votes
Manav Shah
Contributor
October 7, 2025

@Bill Sheboy @Mikael Sandberg thanks for your responses. I have updated my query in a bit detail now. Please let me know if you are able to understand my issue and help me out

Suggest an answer

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

Atlassian Community Events