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

Using inline conditional logic in email action

Braxton Wilkinson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 14, 2021

Hello, 

I am trying to create a system that gathers weekly data and builds a report to send out in a weekly email. I am using the schedule trigger for every 7 days with a JQL search condition that returns a list of items that have been updated in the last week to a send email action. The goal is to have two lists: One for items that have been created in the last week, and another for items that have been updated in the last week. 

In the body of the email action, I have been attempting to use if statements to parse out items from the list and display them in the desired fashion. However, I have not been able to get the if statements to function. I have found contradictory information on this site for how to format the if statements. Here is what I have at the moment:

{{#issues}}
{{#if(created.gt(now.minusBusinessDays(5)))}}
<a href="{{toURL}}">{{key}}</a> was created on {{created.shortDate}}
{{/}}
{{summary}}
Updated on {{updated.shortDate}} at {{updated.shortTime}}
Assignee: {{assignee.displayName}}
Status: {{status.name}}
.
{{/}}

I have tested with several different conditions, including ones that should always return true, without luck, even though the rest of the message executes properly. One comment I found suggested putting spaces in front of the #if and / characters, but that seemed to make the if statement execute every time even if the condition was untrue.

Any suggestions on how to fix my formatting to get these statements to work would be much appreciated. 

Note: I am not using Jira Cloud, if that matters

2 answers

0 votes
Yvan Martin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 19, 2021

Hi there @Braxton Wilkinson

Developer from Automation here.

Looking at your inline if condition the problem isn't with the if condition itself but the comparison functions you are using for date fields. gt/lt are not supported in date fields you would either have to convert to number format like days, or just use either isAfter or isBefore.

You can see a list of date functions here: https://support.atlassian.com/jira-software-cloud/docs/smart-values-date-and-time-functions/

My suggestion is to setup a manual trigger for your rule to test and use a log action with the if condition to see what's being returned inside that if block. Something like this should work for your rule: {{#if(created.isAfter(now.minusBusinessDays(5)))}}

If you require further help with this rule you can get in contact with Atlassian support: https://support.atlassian.com/

Hope this helps.

0 votes
Curt Holley
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 15, 2021

Hi @Braxton Wilkinson 

 

Welcome to the Atlassian community.

My (very simple) suggestion would be to separate them out into 2 rules/emails.

But beyond that, this may prove helpful: Solved: Can conditional operators be used in emails create... (atlassian.com)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events