Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,998
Community Members
 
Community Events
176
Community Groups

If condition doesn't work as expected

Edited

I have an automation rule with embeded "If-else" conditions within "If" conditions. 

I expect the "if-else "conditions to be exclusive (if one is met, then the rest is not evaluated).

I expect the "If" conditions to be inclusive (even if the first "if" is met, the rest of the "If" is evaluated). Likewise, when the first "If" is not met, then the second "If" should be evaluated.

 

Below the image of most of my rule. When the rule is executed, it evaluates the first "if "(red arrow) and if it is met, it evaluates the "if-else". However it never actually gets to evaluate the second "if" (2nd red arrow). 

Any ideas why?

 

Automation1.png

3 answers

1 accepted

1 vote
Answer accepted
Mykenna Cepek Community Leader Jan 26, 2022

The original post said:

I have an automation rule with embeded "If-else" conditions within "If" conditions. 

Actually, the rule you posted has a series of IF and IF-ELSE conditions. No conditions are "embedded" or nested. Jira Automation, to my knowledge, cannot nest conditions (although conditions may be used inside a branch).

Your rule is a linear series of steps. Regarding conditions:

  • IF A THEN B ELSE C will execute either B or C, and then always continue after the condition.
  • A simple IF will terminate the rule if the condition(s) it evaluates is false.

Hope that helps!

Thanks for your reply Mykenna. That makes it clearer. 
I tried using the brach, but it won't allow if-else conditions. 
I need a rule with 2 levels of if-else conditions.

Is there any way to achieve that with automation?

Something like this:

If Field_1 is A then
    change_1.a
    If Field_1.1 is A.1 then
        change_1.a1
    else if Field_1.1 is A.2 then
        change_1.a2
    else
        change_1.a3
else if Field_1 is B then
    change_1.b
    If Field_1.1 is B.1 then
        change_1.b1
    else if Field_1.1 is B.2 then
        change_1.b2
    else
        change_1.b3

Mykenna Cepek Community Leader Jan 27, 2022

Yes, you can achieve this in automation another way. (This is where my 20+ years as a software developer comes in handy...)

You can replace nested IF-THEN-ELSE conditions with a single IF-THEN-ELSE by adjusting the conditions appropriately. I've converted what you posted above to illustrate how to do that:

If (Field_1 is A) and (Field_1.1 is A.1) then
        change_1.a1
    else if (Field_1 is A) and (Field_1.1 is A.2) then
        change_1.a2
    else if (Field_1 is A) and (Field_1.1 is not A.1) and (Field_1.1 is not A.2) then
        change_1.a
    else if (Field_1 is B) and (Field_1.1 is B.1) then
        change_1.b1
    else if (Field_1 is B) and (Field_1.1 is B.2) then
        change_1.b2
    else if (Field_1 is B) and (Field_1.1 is not B.1) and (Field_1.1 is not B.2) then
        change_1.b

Hi @Iana Encarnacion,

Automation is designed so that, if a condition fails, no actions following it will be performed. The "if/else" condition is actually an exception: if a condition fails, then we go to the next "else", then to the next one, and so on.

Hope this helps!

- Manon

Thanks for clearing that out Manon! 

0 votes
Pramodh M Community Leader Jan 26, 2022

The second will not be evaluated, that is how it works

Pramodh M Community Leader Jan 26, 2022

If any condition fails Automation will stop at that point!! Better use branching to separate the checks here for your requirement

Like Iana likes this

Thanks for your reply. Do you have an idea on how I could have 2 levels of if-else conditions using the branching? 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events