Is it possible to have multiple if statements in content field?

Peter Johansson March 9, 2021

Hi,

I have an automation with a if/else block. In one of the blocks I'm sending an e-mail. In the content of the e-mail I would like to have two different if statements checking smart-values.

The values comes from a custom checkbox field and I've created smart-value variables, i.e. value1 and value2, that has the value from the checkboxes.

Currently I have this syntax and it is working fine as long as value1 is true. If value1 is false then the next if statement doesn't execute.

{{#if(value1.equals("Prod"))}}_Prod_user{{/}}
{{#if(value2.equals("QA"))}}_QA_user{{/}}

How can I have more than if statement that evaluates independent of each other?

Kind regards,
Peter

3 answers

1 accepted

0 votes
Answer accepted
Peter Johansson March 17, 2021

Problem solved!

When creating smart variables {{production}} and {{qa}} using {{issue.Tools - Environments.get(0)}} and {{issue.Tools - Environments.get(1)}} the {{qa}} variable was empty if QA checkbox was ticked. Then {{production}} gets the value "QA".

0 votes
Sam Harding
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 9, 2021

Hi @Peter Johansson 

What you have done should work. I have just verified that multiple if statements can be done as you are trying in smart value templates. There must be some other issue at play here.

Can you put a Log Action and print out value1 and value2, as well as log the double if statement result? Does your rule have any conditions in it relating to value1 which may be preventing the rule from reaching the final component?

Cheers

Sam

Peter Johansson March 10, 2021

Hi @Sam Harding  

Thanks for verifying that it should work!

I added these debug function calls in the content of the send email action

{{#debug}}{{production}}{{/}}
{{#debug}}{{qa}}{{/}}
{{#debug}}{{if(production.equals("Production"))}}{{/}}
{{#debug}}{{if(qa.equals("QA"))}}{{/}}

The output 

  • Production checkbox ticked: Production, true
  • QA checkbox ticked: QA
  • Both checkboxes ticked: Production, QA, true 

Seems that the problem is when {{production}} evaluates to false further execution stops.

{{production}} and {{qa}} (referred to as value1 and value2 in previous response) are created using the create variable action and gets its value using {{issue.Tools - Environments.get(0)}} and {{issue.Tools - Environments.get(1)}}. The custom field Tools - Environments has two options; Production and QA.

When the automation is run the content of the email shall be adapted based on the ticked checkboxes, e.g. if Production is ticked a specific user group will be written in the content. That user group shouldn't be viewable in the service desk form.

The send email action is part of an if-else block looking like thisif-else.png

The automation if-else part works as it should and the email is being sent but the content of the email is not correct when it comes to the checkbox smart value logic.

Any thoughts or ideas are more than welcome!

Cheers,
Peter

0 votes
Clark Everson
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2021

Hi @Peter Johansson ,

 

This is for automation for Jira correct? If so you can but you need to have them as branches of the transition for current issue. And under the branch issues you put the values. 

 

Best,
Clark

Clark Everson
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2021

Screen Shot 2021-03-09 at 9.06.02 AM.png

Peter Johansson March 9, 2021

Hi @Clark Everson ,

Thanks for your reply!

To be even more clear, it is in the content of an send e-mail action that I want to have multiple if statements.

2021-03-09 151023.png

Best,
Peter

Suggest an answer

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

Atlassian Community Events