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,463,706
Community Members
 
Community Events
176
Community Groups

Using inline conditional logic in email action

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 Aug 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 Aug 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

Atlassian Community Events