Create Automation to send one email for a list of closed tickets
Asked by Hoa Walsh:

Hi Jira Community!

I am trying to use automation to send one email with a list of closed tickets with some details like the key, summary, assignee, and last comment, for each closed ticket.

I found article "Run a rule against issues in bulk" (URL: <https://confluence.atlassian.com/automation/run-a-rule-against-issues-in-bulk-993924653.html> ) but I think it might be dated because when I ran the automation, it generated an email for each ticket instead of one email with a list of tickets. Below are my setup and log.

The JQL:

(project = FS AND assignee IN (712020:f033c51b-9d71-4374-88f0-d41003981be4, 712020:e19a5a7e-cdc8-4104-b87c-9dd3953df1f9) AND status IN (Cancel, Canceled, Closed, Completed, Declined, Done, "Done -", Failed, Resolved) AND resolved \>= -1d)

![2024-09-05 22_30_18-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png](/t5/image/serverpage/image-id/345912i121BD49B6F404951/image-size/large?v=v2&px=999 "2024-09-05 22_30_18-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png")![2024-09-05 22_30_25-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png](/t5/image/serverpage/image-id/345913iC12C2A021FB61D0D/image-size/large?v=v2&px=999 "2024-09-05 22_30_25-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png")![2024-09-05 22_29_55-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png](/t5/image/serverpage/image-id/345914iF1042DB20D1A2774/image-size/large?v=v2&px=999 "2024-09-05 22_29_55-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png")

Please let me know what I am missing.

Thank you! Hoa W


Answers:
author: Trudy Claspill
body: Hello [@Hoa Walsh](/t5/user/viewprofilepage/user-id/5575878)

When you put the JQL in the Scheduled trigger then the actions in the rule will be executed for each issue.

Instead put the JQL in a Lookup Issues action. You can then add the entire result set into one email using syntax like this

```
{{#lookupIssues}}
names of fields in the issue
{{/}}
```

comments: author: Hoa Walsh
body: Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) !

You've been very patient and helpful in helping me with my ask and I truly appreciate it! I am a beginner to jira automation, and your assistance has been instrumental in my team's success. So again thank you so much!! \<3

With that said, I did move the JQL to the lookup issue action and added the lookup fields and I notice the log shows the information but when the email was sent, it doesn't seem to pull the same information.

![2024-09-06 09_36_58-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png](https://community.atlassian.com/t5/image/serverpage/image-id/346010i301ACFC87C0923C1/image-size/large?v=v2&px=999 "2024-09-06 09_36_58-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png")![2024-09-06 09_33_39-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png](https://community.atlassian.com/t5/image/serverpage/image-id/346011i2B965FA69D069381/image-size/large?v=v2&px=999 "2024-09-06 09_33_39-Audit log - Automation - Financial Systems - Jira ? Mozilla Firefox.png")

Hoa


author: Trudy Claspill
body: Hello [@Hoa Walsh](/t5/user/viewprofilepage/user-id/5575878)

Your syntax is incorrect here:

![Screenshot 2024-09-06 at 8.53.13?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/346018iDF63C7DC37DF031D/image-size/large?v=v2&px=999 "Screenshot 2024-09-06 at 8.53.13?AM.png")

If you want the header text to appear only once, put it before the {{#lookupIssues}} tag.

Between the {{#lookupIssues}} and {{/}} tags list just the field names and don't use curly braces.

```
Ticket,Created,Assignee,Requestor,Summary,Last Comment.Resolved
{{#lookupIssues}}
key,created,assignee.displayName,summary,last.comment,resolved
{{/}}
```


author: Hoa Walsh
body: Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/5120046) ,

I copied your syntax and tried again but the email shows the value as text.

![2024-09-06 11_18_11-Rule builder - Automation - Financial Systems - Jira ? Mozilla Firefox.png](https://community.atlassian.com/t5/image/serverpage/image-id/346039i58C5380AA83FE0B4/image-size/large?v=v2&px=999 "2024-09-06 11_18_11-Rule builder - Automation - Financial Systems - Jira ? Mozilla Firefox.png")

But the log still show the ticket details correctly.

![2024-09-06 11_19_21-issue resolve this week - Message (HTML).png](https://community.atlassian.com/t5/image/serverpage/image-id/346040i52703506DCFEFD64/image-size/large?v=v2&px=999 "2024-09-06 11_19_21-issue resolve this week - Message (HTML).png")

So when using the lookup smart values (ie {{lookupIssues.key}}), this doesn't show values in the email but it does in the log.

When I use your syntax in the log, it doesn't pull back the values in the log either. So I have a feeling the {{lookupIssues.key}} smartvalues is the way to go, at least in the log.

Just for "kicks and giggles", I use the syntax that I had tested out a couple nights ago (I can't find the source to reference here, I will update if I do) and it worked! I'll have to play around with the fields I need but this is getting me to the right track!

![2024-09-06 11_28_38-issue resolve this week - Message (HTML).png](https://community.atlassian.com/t5/image/serverpage/image-id/346042iC5372D02A5741084/image-size/large?v=v2&px=999 "2024-09-06 11_28_38-issue resolve this week - Message (HTML).png")

Thank you!

Hoa


author: Trudy Claspill
body: My apologies! I made a mistake.

Within the email content you do need the curly braces around the field names:

{{key}},{{created}}, etc.

<https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Lookup-issues>


author: Hoa Walsh
body: Aaahhhh! Thank you! Two steps closer to what I"m trying to achieve.

Now to figure out why the comment only display for the last ticket and not each of the ticket, before that.

![2024-09-06 12_55_21-issue resolve this week - Message (HTML).png](https://community.atlassian.com/t5/image/serverpage/image-id/346052i4C64F14365387814/image-size/large?v=v2&px=999 "2024-09-06 12_55_21-issue resolve this week - Message (HTML).png")


author: Trudy Claspill
body: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--issue.comments-->

Try this instead:

{{comments.last.body}}


author: Hoa Walsh
body: That did the job! I don't know what to say anymore. LOL

You're the best!! Have a great weekend!

Hoa


Tags: cloud

jira-cloud