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

Conditional If/Else within Send Email Action

Alex October 24, 2024

Not sure if this is possible, but worth a shot.

I have an automation that successfully goes through epics, and reports via email. The child issue types of an epic are "Project Risk", "Project Blocker", "Project Decision". 

I am able to report each issue type in a specific section of the email, by using the following:

 


Blockers

{{#lookupIssues}}

{{#if(equals(issueType.name, "Project Blocker"))}}

Blocker: {{summary}} | {{status.name}}

  • Risk Impact: {{Risk Impact}}
  • Mitigation Plan: {{Mitigation Plan}}

{{/}}

{{/lookupIssues}}


My question is, if (in this example) there are NO Blockers, the section in the email is blank.

I would love for it to have some conditional logic within the email action that says "There are no Blockers." IF there are indeed no blockers.

 

Additionally, I only want it to write "There are no Blockers" one time. Not iterate through and write it multiple times (depending on the lookup results).

 

Thoughts?

 

1 answer

1 accepted

3 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.
October 24, 2024

Hi @Alex 

Yes, that is possible, and could be done outside of your iterator over the values.  And there are several ways to do this...

 

One inefficient way is... to use multiple calls to Lookup Issues, adjusting the JQL for each issue type, and then save each result's formatted output in a variable.  Then check if that variable is empty to show your "There are no X" messages.

 

Staying with one Lookup Issues action call, you could still use filtering and generate a count for each type, storing that in a created variable, and then use those variables to decided if the message should be shown.

  • action: create variable
    • name: varProjectBlockerCount
    • value:
{{#=}}0{{#lookupIssues}}{{#if(equals(issueType.name, "Project Blocker"))}}+1{{/}}{{/}}{{/}}
  • ...and so on for the other issue types
  • action: send email
    • in the body...
some text...

{{#if(equals(varProjectBlockerCount, "0"))}}There are no Project Blockers.{{/}}
{{#lookupIssues}}
{{#if(equals(issueType.name, "Project Blocker"))}}
Blocker: {{summary}} | {{status.name}}
* Risk Impact: {{Risk Impact}}
* Mitigation Plan: {{Mitigation Plan}}

{{/}}
{{/}}


...repeat for other types

 

Please note that the "0" in the check is in quotation marks as variables are text.  If you want that to check 0 instead, you may convert the variable using asNumber.

 

Kind regards,
Bill

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2024

Dude. This is very very slick.

That is all. :-O

Like # people like this
Alex October 24, 2024

@Bill Sheboy  - very slick indeed. Worked like a charm. Just fyi, 

{{#=}}0{{#lookupIssues}}{{#if(equals(issueType.name, "Project Blocker")}}+1{{/}}{{/}}{{/}}

was missing a closed parenthesis - but otherwise, perfecto.

 

Thank you so much.  

Like Bill Sheboy 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 24, 2024

Thanks, and oops!  That's what I get for typing stuff like this without trying it first, or using a code editor :^)

I updated my first post so the initial one has your correction.

Alex October 24, 2024

Your skill and contributions buy you a mistake once in a blue moon :)
Thanks again!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events