1 Notification per assignee via Automation on Jira
Asked by Nicolas Zuderell:

If I make a JQL query "Sprint in openSprints() and statusCategory != Done" and there are for example 10 Issues found. -\> Now I split the query again so that I only have the tickets with the assignee XYZ, let's say 5 of 10 issues are assigned to XYZ. -\> Assignee XYZ should now be notified that these 5 tickets are still open via MS Teams or mail.

Now my problem:  
{{#lookupIssues}}  
\* {{url}}  
{{/}}  
With this smartvalue I get a list of all issues in the above query, **BUT** assignee XYZ now gets 5 messages with the same content.

Can this be reduced so that he is notified only once?


Answers:
author: Bill Sheboy
body: Hi [@Nicolas Zuderell](/t5/user/viewprofilepage/user-id/4828770) -- Welcome to the Atlassian Community!

For a question like this, please post images of your complete automation rule and of the audit log details showing the run of the rule which does not work as expected. That will provide context for the community to offer suggestions. Thanks!

Until we see that information, I suspect your rule has a scheduled trigger on JQL, leading it to run for each issue in the trigger set. The solution may be to remove the JQL from the trigger and just run on a scheduled...using the JQL exclusively for your lookup issues action. Then only one email will be sent.

Kind regards,  
Bill

comments: author: Nicolas Zuderell
body: Thanks Bill to your answer it helped me with my MS Teams notification.  
On the Mail i will get this message:  

![2022-03-21_Audit_log-Jira.png](https://community.atlassian.com/t5/image/serverpage/image-id/189171i347007E58A7BAECD/image-size/large?v=v2&px=999 "2022-03-21_Audit_log-Jira.png")

This is my rule:

![2022-03-21_rule-settings-Jira.png](https://community.atlassian.com/t5/image/serverpage/image-id/189172i3FEE9EA8D21F8716/image-size/large?v=v2&px=999 "2022-03-21_rule-settings-Jira.png")

Do I need a step more or do I something wrong?  

Best Regards  
Nicolas


author: Bill Sheboy
body: Once you removed the JQL from the scheduled trigger, the Send Email now needed another source for that issue information: Lookup Issues.

Please try using {{lookupIssues.size}}


author: Nicolas Zuderell
body: I have removed all JQL from the trigger and i still get the error from above in the audit log.  
I deleted the JQL before i unchecked the box:![2022-03-22_triggered_scheduler.png](https://community.atlassian.com/t5/image/serverpage/image-id/189272i845DED888E801A25/image-size/large?v=v2&px=999 "2022-03-22_triggered_scheduler.png")

also i removed the smart value in the subject of the mail. the content is still to the assignee of the ticket:  
{{#lookupIssues}}  
\* {{url}}  
{{/}}


author: Bill Sheboy
body: Would you please post images of:

* the details of your send email action
* the details of the audit log showing the error after you made the changes to the rule

That may indicate what is happening.

The other possibility with Jira Cloud automation rules is they sometimes get "glitched" by changing the components to many times. The way to test that is to disable this rule and re-create it as a new rule and see if that works.


author: Nicolas Zuderell
body: Email action:

![2022-03-23_sendMail-settings.png](https://community.atlassian.com/t5/image/serverpage/image-id/189503i9216A4829A7A43F3/image-size/large?v=v2&px=999 "2022-03-23_sendMail-settings.png")

And here the log between the changes:

![2022-03-23_auditlog.png](https://community.atlassian.com/t5/image/serverpage/image-id/189504i39A6526258D43470/image-size/large?v=v2&px=999 "2022-03-23_auditlog.png")

i have recreated the rule with the same actions and triggers it dont works neither.

if i put my own mail adress in the "to-section" it works. If i put the assignee (like the first screenshot in this comment) it brings the "some errors" warning


author: Bill Sheboy
body: Ah...got it. *Assignee* in that context for the to-email-address is undefined, as there is no issue. They are all in the Lookup Issues result.

The way to solve this is to get the email address from the lookup, and add a safety check condition with this:

* trigger: scheduled...
* action: lookup issues...
* advanced compare condition...
  * first value: {{lookupIssues.size\|0}}
  * condition: greater than
  * second value: 0
* action: send email with the to-email-address of {{lookupIssues.first.assignee.emailAddress}}

For the email address, type/pasted that smart value into the field and it will appear below it, then you can select it.


author: Nicolas Zuderell
body: Thank you!


author: vdhanorkar
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) Thanks for the steps, i tried the same but in my case one assignee received a mail but another did not. could you please suggest? please see attached screenshot

![Image-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/208416iA6C61067F42DA080/image-size/large?v=v2&px=999 "Image-1.png")

Email:

![Image-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/208417i0AF8BECE7B49878A/image-size/large?v=v2&px=999 "Image-2.png")

Also i don't want to send other assignee's tasks details in mail body, both assignee should receive only their own task details in mail body.


author: Bill Sheboy
body: Hi [@vdhanorkar](/t5/user/viewprofilepage/user-id/4354367)

Your use case is different as there could potentially be multiple different assignees. As a result you need a different rule, as what you posted references only the first assignee from the lookup issues result.

One possible way to do that is:

* trigger: scheduled
* action: lookup issues with JQL
* condition: check if there were any results before proceeding
* [advanced branch on smart values](https://community.atlassian.com/t5/Automation-articles/Branching-over-smart-values-in-Jira-Automation/ba-p/1741935): on the [distinct](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#list.distinct) assignees found, using the lookup issues as a source from {{lookupIssues.assignee.accountId.distinct}} and a loop variable named varAccountId
  * action: lookup issues with the same original JQL, plus the clause assignee = {{varAccountId}
  * action: send your email

Kind regards,  
Bill


author: Darryl Lee
body: Ohai Bill!

So as I laid out in my answer to [@vdhanorkar](/t5/user/viewprofilepage/user-id/4354367)'s standalone question [over here](https://community.atlassian.com/t5/Automation-questions/Is-there-a-way-to-send-one-email-to-one-assignee-with-email-body/qaq-p/2090989#M4507), I actually branched on **{{lookupIssues.assignee.distinct}}** in the "For each" so that I could access **{{thisassignee.accountId}}** for the nested JQL lookup and also use **{{thisassignee.emailAddress}}** for the **To:** in the email.


author: vdhanorkar
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) Thanks, The solution you suggested working to me


author: Zaldy Parian
body: Hi [@vdhanorkar](/t5/user/viewprofilepage/user-id/4354367) ,

Would you mind posting screenshots of your automation here? I'm also looking to send 1 email to all assignees. The body of an email includes all issues returned by a JQL filter. The list of issues is formatted in a table.

I got it all working, except for all assignees. As you can see in the snippet below, I included both {{lookupIssues.assignee.displayName}} and {{lookupIssues.assignee}}. But the actual email sent every Tuesday morning did not include any of the assignee.

![automation1.png](https://community.atlassian.com/t5/image/serverpage/image-id/243038iC6CA3C4F69DA848E/image-size/large?v=v2&px=999 "automation1.png")

Thanks for your help.


author: Bill Sheboy
body: Hi [@Zaldy Parian](/t5/user/viewprofilepage/user-id/1191073)

Just to confirm...your scheduled trigger does NOT have JQL, correct?

If so, it appears you want to send that email to all possible assignees for the issues in the lookup issues result. To do that, please update the email TO with the below expression.

```
{{#lookupIssues}}{{assignee.emailAddress}};{{/}}
```

That will iterate over the lookup results and add each assignee's email address, followed by a delimiter.

If that sends duplicates to the same assignee, you can adjust that using *distinct* like this:

```
{{#lookupIssues.assignee.emailAddress.distinct}}{{.}};{{/}}
```

Kind regards,  
Bill


author: Zaldy Parian
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

Appreciate your quick response.

The Then: Lookup issues has filter as shown below.

![automation2.png](https://community.atlassian.com/t5/image/serverpage/image-id/243044i93BABD204004970D/image-size/large?v=v2&px=999 "automation2.png")

I added in the To: field of the email your suggestion of

{{#lookupIssues}}{{assignee.emailAddress}};{{/}}

but still no luck. Only the emails from the customfield_10174 are receiving the email.


author: Bill Sheboy
body: Would you please write that smart value expression to the audit log, and then post an image of what it includes after the rule runs?


author: Zaldy Parian
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

Apologies for my ignorance; but how do I write the smart value to the audit log? Last time i executed the automation, it was successful, but the recepients supposed to be included in {{#lookupIssues}}{{assignee.emailAddress}};{{/}} did not receive an email. Only those in {{lookupIssues.customefield_10174}} got an email.

Here's a grab of the audit log. Though the issues were included in the successful associated items, the email did not include the email address of assignee.

![automation3.png](https://community.atlassian.com/t5/image/serverpage/image-id/243291iBD2AEB67A4E1498D/image-size/large?v=v2&px=999 "automation3.png")

Can you please elaborate on audit log?


author: Bill Sheboy
body: There is a rule action named [Log](https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Log-action) which allows writing text or smart values to the audit log. Please add that action to your rule after the lookup issues action, including this:

```
Here are the expected assignees: {{#lookupIssues.assignee.emailAddress.distinct}}{{.}};{{/}}
```


author: Zaldy Parian
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

I think you suggestion is working. The Log action display distinct emails of all Assignees.  
I'll put the same smart value in the To: field of the email and see how it goes next week in its next scheduled run.

![automation4.png](https://community.atlassian.com/t5/image/serverpage/image-id/243570i5961AB35F39B0D11/image-size/large?v=v2&px=999 "automation4.png")

Thanks very much for your patience and kind support.

Cheers,


Tags: assignee

cloud

email

notification