Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Excluding lookup objects using an if inside an email

Toby Jackson
March 23, 2026

I am trying to create a report of items that have exceeded an approved testing days field. To do that I am comparing the difference between 2 dates and then comparing with another field. I have tried many different iterations of the {{#if }} but I can't see to get the if statement to run in any scenario, can someone let me know if this is possible and what syntax changes I need to make it work? 

 

My code is below:

I am using a table like below, and I have got it looping through the items without a problem but I can't get the if statement to trigger correctly. This code is within JIRA automation Customised email object, where the content type is set to HTML. 
<table> <tr> <th>Issue Key</th> <th>Instance</th> <th>Summary</th> <th>Account</th> <th>Planned Start</th> <th>Approved Days</th><th>Age (days)</th> </tr> 
{{#lookupIssues}}
    {{ #if(gt(Planned start.diff(Planned end).days, customfield_11661.asNumber))}}<tr><td><a href="{{url}}" style="color: #1963d1; text-decoration: none;">{{key}}</a></td><td>{{customfield_11558}}</td><td>{{summary}}</td><td>{{customfield_11491}}</td><td>{{customfield_10070.jiraDate()}}</td><td>{{customfield_11661}}</td><td>{{customfield_10070.diff(today()).days}}</td></tr>{{ /}}
{{/lookupIssues}}

1 answer

1 accepted

2 votes
Answer accepted
Marc -Devoteam-
Community Champion
March 23, 2026

Hi @Toby Jackson 

Also you closure statement is not correct, it is just {{/}}, not {{/lookupIssues}} and the closure before contains a space, see {{ /}}

Toby Jackson
March 23, 2026

Thank you for your reply but unfortunately I have tried many variations. If I simplify the content of the email to the below, it still doesn't go into either the if or else blocks, and no errors are thrown either. 

{{#lookupIssues}}
{{#if(gt(Planned start.diff(Planned end).days, customfield_11661.asNumber))}}
If result
{{else}}
Else result
{{/}}
{{/}}
Marc -Devoteam-
Community Champion
March 23, 2026

Hi @Toby Jackson 

There is no Else option.

I can't seem to grasp your logic. 

{{#if(gt(Planned start.diff(Planned end).days, customfield_11661.asNumber))}} is the field 11661 already populated?

This as a the date diff gives a valuer back in days already.

gt function can only be used after and in a calculation not with dates.

What if you do (as test)

First make sure field 11661 is set based on date diff.

Then lookup the issues with this field set.

{{#lookupIssues}}
{{#if(customfield_11661.gt(2))}}
{{key}}
{{/}}
{{/]}

Toby Jackson
March 23, 2026

I managed to get it to work thank you. It was a simple syntax issue, this is what resolved the problem for me. 

{{#if(Planned start.diff(Planned end).days.gt(customfield_11661))}}

Like # people like 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 Champions.
March 23, 2026

Hi @Marc -Devoteam- 

FYI -- Although there is no {{else}} in smart value syntax / functions, there is a variant of the if() function which supports true or false results:

{{if(smartValue, "value if true", "value if false")}}

Please note well:

  • there is no preceding pound # sign in this function; the one with pound # only handles the true case as a section rather than inline
  • because the true and false values are expected to be strings, there are lots of limitations on what does (and does not) work with this function for those values
  • and...this conditional function seems to have more limitations when used inside of a long-format list iterator: it does not filter, values can be misinterpreted, etc.
  • I recommend testing a lot when deciding to use this function

 

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events