Forums

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

Email Automation - Look up -

Melissa C
Contributor
September 1, 2026

Hello, 

I have an email automation that I use to send a weekly report.  I have a jql that gathers all the results. If the status is closed it will list the results in a table.  This has been working perfect! But when there is a table with no results I would like it to say "None"

This is the code I'm using 
I've attempted to add {{#if(equals(lookupIssues.size,0))}} But it's not working. 

Any suggestions? 


------------------------------------------------------------------

<table >
<tbody>
<tr>
<th colspan="7" style="background-color: #AAD5FF; Padding: 10px" >Closed items for  Week Ending - {{now.minusBusinessDays(1).longDate}}</th>
<tr/>
<tr>
<th style="background-color: #DDEEFF"><b>Epic Link</b></th>
<th style="background-color: #DDEEFF"><b>Key</b></th>
<th style="background-color: #DDEEFF"><b>Summary</b></th>
<th style="background-color: #DDEEFF"><b>Document Link</b></th>
<th style="background-color: #DDEEFF"><b>Comments</b></th>
<th style="background-color: #DDEEFF"><b>Assignee</b></th>
<th style="background-color: #DDEEFF"><b>Updated</b></th>
</tr>

{{#if(equals(lookupIssues.size,0))}}
<tr>
<td colspan="7" style="text-align:center;font-weight:bold;">None</td>
</tr>
{{/}}
{{#Issues}}
{{#if(equals(status.name, "Closed"))}}

<tr>
<td>
<a href="{{epic link.url}}">{{epic link.epic name}}</a></td>
<td>{{Key}} </td>
<td>{{summary}}</td>
<td><a href="{{epic link.Document Link}}">{{epic link.epic name}}</a></td>
<td>{{customField_11726}}</td>
<td>{{Assignee.displayName}}</td>
<td>{{Updated.shortDate}}</td>
</tr>
{{/}}
{{/}}
</tbody>
</table> </div>

2 answers

1 vote
Varun Chillamcharla
Contributor
September 1, 2026
 
I think lookupIssues.size is counting all issues from your lookup, not just the ones actually "Closed" after your inner filter. So if the JQL pulls back mixed statuses, size can be greater than 0 even when nothing ends up rendering, which is why "None" never shows.
 
Best fix: update the JQL in your Lookup Issues action to filter status = Closed directly. Then lookupIssues.size will actually match what renders, and you can drop the redundant status check inside the loop.
 
Also worth double checking, your loop uses {{#Issues}} but your size check uses {{lookupIssues.size}}, make sure those are actually the same variable name, a mismatch there would cause this to silently fail too.
Melissa C
Contributor
September 1, 2026

Thank you @Varun Chillamcharla 

So my jql (see below) actually gets a list of items, Approved item and then Tasks that include Requirements Completed, in the summary. In the email I have two tables
Table 1. Lists all of the Tasks
Table 2. All of the Approved Items


Because this works well I'm afraid to change it!


(project in (60740)) AND status changed from CANDIDATE to (APPROVED) during (startOfWeek(-1), endOfWeek(-1)) AND status not in (Implemented, Rescinded, Candidate) OR summary ~ "\"Requirements Completed\"" AND issueFunction in issuesInEpics("status in (Approved, Implemented) ") AND resolved >= startOfWeek(-1) AND updated <= endOfWeek(-1))

Varun Chillamcharla
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.
September 1, 2026
 
No need to touch your JQL. Add a Create Variable action before your table (call it taskCount) with:
 
{{#Issues}}{{#if(equals(status.name, "Closed"))}}1{{/}}{{/}}
 
That builds a string of "1"s, one per matching Closed issue. Then check {{taskCount.length}} instead of lookupIssues.size:
 
{{#if(equals(taskCount.length,0))}}
 
Since it's empty when nothing matches, .length correctly comes out as 0, and it only counts issues that actually pass your Closed filter. Do the same with a separate variable for your Approved Items table. Your JQL and existing setup stay untouched, you're just adding an accurate count alongside it.
Gabriela - LeanZero
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.
September 1, 2026

Varun's read on the mismatch is right, and there's a small syntax thing that will make his fix look like it didn't work.

Text functions take parentheses, list functions don't, and it catches people out. The docs show text as "{{issue.summary.length()}} -> 12" and "{{issue.summary.isEmpty()}} -> false", while the list forms appear bare: "This bug has {{issue.issuelinks.size}} related tickets" and "{{#if(not(issue.issuelinks.isEmpty))}}". Your taskCount is a string, so it wants taskCount.length() with the brackets. Across that page the bracketed form is the only one shown, and the list page shows only the bare form, so the split holds throughout the docs rather than in a single example.

If your JQL already returns only what the table should show, you can skip the counting variable entirely and use the list form directly: {{#if(lookupIssues.isEmpty)}}None{{/}}. The counting approach earns its keep only when you filter inside the loop, which is the case Varun spotted in your template.

The thing I'd check before either, though, since it changes what any of these counts mean. The Lookup action reads at most 100: "When entering a JQL query for the Lookup work items action, only the first 100 work items will be used", and the action's own description is "Search for up to 100 work items using a JQL query." It doesn't warn you when it hits that. It stops. On a weekly report that's fine until a busy week quietly loses rows, and a count built on the truncated list will agree with the truncated table, so the two will look consistent while both being short. Run the same JQL in the issue navigator once and compare its total against what the email prints.

Varun Chillamcharla
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.
September 2, 2026
Thanks @Gabriela - LeanZero, both good catches. You're right on .length() needing the parentheses for text values, and the 100-item Lookup cap is a really important flag for a recurring report, that's exactly the kind of thing that fails silently and would be easy to miss until a busy week quietly drops rows.
 
@Melissa C Melissa, worth double checking against @Gabriela - LeanZero point, if your JQL can occasionally return more than 100 matching items in a busy week, you'd want to either narrow the JQL further or account for that limit directly, otherwise the report (and any count built from it) could understate reality without any obvious error.
0 votes
Sami Shaik
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.
September 3, 2026

Hello @Melissa C , the condition is close, and it fails for one reason worth knowing because it bites everywhere in automation: when a Lookup work items action returns no rows, {{lookupIssues.size}} is empty (null), not 0. So {{#if(equals(lookupIssues.size,0))}} compares nothing to zero and is never true, and your "None" branch never renders.

The fix is to give the size a default before comparing:

{{#if(equals(lookupIssues.size|0,0))}}
None
{{/}}
{{#if(lookupIssues.size.gt(0))}}
<table>
  <tr><th>Key</th><th>Summary</th><th>Status</th></tr>
  {{#lookupIssues}}
  <tr><td><a href="{{url}}">{{key}}</a></td><td>{{summary}}</td><td>{{status.name}}</td></tr>
  {{/}}
</table>
{{/}}

The |0 is the default-value operator: empty becomes 0, and the comparison works. The second block is guarded separately so the table markup only renders when there is something to put in it (an empty {{#lookupIssues}} loop inside a table is what leaves you with a header row and nothing under it).

Two equivalent forms if you prefer them: {{#if(lookupIssues.isEmpty)}}None{{/}} uses the documented list function (smart values for lists), and if you would rather branch in the rule than in the template, an If/else block with an advanced compare condition on {{lookupIssues.size|0}} equals 0 lets you send two different emails instead of one template with both branches.

One caution on the loop itself: only a limited set of fields is available inside {{#lookupIssues}} (summary, status, assignee, key and a few others; most custom fields, labels and components are not), so if a column comes back blank inside the table, that is the cause rather than the conditional (Atlassian KB on empty smart values). Conditional-logic reference: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

Suggest an answer

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

Atlassian Community Events