Nested IF/ELSE Automation

Harsh
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.
August 25, 2023

I have an  automation as follows 


Trigger- Value changed for customfield_123 for Create and Edit Issue

If customfield_123 contains A

then add component - A

else - If customfield_123 does not contains A

then remove the component - A

 

else - If customfield_123 contains B

then add component - B

 

else - If customfield_123 does not contains B

then remove the component - B

.

.

else - If customfield_123 contains C

then add component - C

 

else - If customfield_123 does not contains C

then remove the component - C




The problem is when I create a ticket customfield_123 as A, or remove the A, it works as expected.

Now when I am creating a new ticket or editing the an existing ticket with customfiled_123 as B, it is not considering the else - If customfield_123 contains B condition. Same thing is select the value as C, it is not checking the condition for C

It is just checking the FIRST 2 if condition and not the others. Is there any restriction on how many if-else we can put in an automation.


I do not want to create multiple automation, is there a way this can be achieved.

Thanks for the help.

 

3 answers

1 accepted

0 votes
Answer accepted
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.
August 25, 2023

Hi @Harsh 

What problem are you trying to solve by synching these two fields when they appear to have the same value?  Would using just one value work?

Kind regards,
Bill

Harsh
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.
August 25, 2023

Hi @Bill Sheboy 

 

The problem is I have to update the component based on the custom field value. And if any of the custom value is not added in the ticket, and delete the respective component, attach to it. 

 

Thanks 

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.
August 25, 2023

I understood that was what you were trying to accomplish with the automation rule. 

Instead I was wondering why not use Components or the custom field, but not both.  What value does your team get from setting both fields to the same value?

Harsh
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.
August 27, 2023

Hi @Bill Sheboy 

I'm just using one value which custom field. 

I'm setting the components value based on the custom field. That's the requirement 

Thanks

0 votes
Bentley_ Andrea November 25, 2024

@Harsh I realize your question is over a year old - did you find a solution? My thought was to have separate, sequential IF statements:

If customfield_123 contains A

then add component - A

else remove the component - A

 

If customfield_123 contains B

then add component - B

else remove the component - B

 

If customfield_123 contains C

then add component - C

 else remove the component - C

 

Would this have worked for you?

0 votes
Rilwan Ahmed
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 25, 2023
Hi @Harsh 
 
Your conditions are overriding each other. 
 
Example: When you say "if customfield_123 does not contains A", this means rule will run for B, C, D etc.
In next loop, you have entered condition "If customfield_123 contains B" and so on.
So system if failing to understand your requirement. 
I would suggest to create rule as follows
 
If customfield_123 contains A
then add component - A
 
else - If customfield_123 contains B
then add component - B
 
else - If customfield_123 contains C
then add component - C
 
else if customfield_123 is empty
Then set component as Empty
Harsh
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.
August 25, 2023

Hi @Rilwan Ahmed 

 

Thanks for the response. Got the point. 

But I want remove the component based on the custom field. 

For example - on create I choose custom field A. It adds component A. 

But now let's say I realised that I wanted to B, instead of A. I edit the value to B. So in this case, I have to check the custom field again, for the previous value was A or not. Same for any value.

 

 

The custom field cannot be empty. It will have some value. if the value of custom field doesn't contain any of A, B,C then component should he empty. So I have to check based on value. I am using advanced compare condition to check the condition 

I'll try your logic. And update you.

Thanks 

Suggest an answer

Log in or Sign up to answer