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
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.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.