Automation - 1 email per Assignee in JQL
Asked by Elliott Lock:

Hi,

Firstly I've really tried to follow guides, everyone seems to be out of date, not have the same options I do etc.

I'm on Jira Software 9.12.1 and I'm trying to utilise Automations to send an e-mail to assignees within a JQL. However, I want to ensure each assignee only receives one email and within that email is all their issues and NOT an email per issue.

Here's an example JQL I want to run:

```
project in ("Super Car") AND fixVersion in ("Version 1.2.1")
```

That JQL might return \~200 results with 15 unique assignees. As a result I want to send 15 emails each containing a list of the issues assigned to them.

I'd appreciate if someone can help me achieve this, or point me to a guide that is correct for my JIRA version?

Many Thanks


Answers:
author: Bill Sheboy
body: Hi [@Elliott Lock](/t5/user/viewprofilepage/user-id/405691)

I do not believe the scenario you describe is easily possible with Jira Data Center automation in *one single rule*. The reasons are:

* triggers, branches, and lookup issues can only reference up to 100 issues at a time
* I do not believe advanced branches (over things other than issues, such as assignees) are supported in Data Center automation rules yet: <https://jira.atlassian.com/browse/JIRAAUTOSERVER-749>

You do not state what the trigger is for your rule, and if I assume it is *version released*, four possible workarounds are:

1. Create one rule, triggered on version released, and use a series of lookup issues actions to test for each possible assignee and if / else blocks to send the emails. This will be a slow rule, and be limited to the maximum rule size of 65 components, and thus could handle at most around 20 possible assignees. If there are more assignees...
2. Create several rules, triggered on version released, where each one tests for a single possible assignee, only sending the email if the issues are found
3. Create two rules, where the first is triggered on version released, which then uses the Send Web Request action to trigger a second rule, triggered on Incoming Webhook. That second rule processes one possible assignee, and then self-triggers with Send Web Request until all possible assignees are checked. This is a risky rule, for many reasons, and so I would not recommend it.
4. Add a site webhook for version released, and use that to trigger a custom application built outside of Jira. That app would use the REST API to gather the issues and send the emails.

Kind regards,  
Bill


author: John Funk
body: Hi Elliott,

I am not sure of what all is available with Automation rules in DC, though I am not sure that you are. You mention 912.1 but then the question has a tag of Jira Cloud.

Regardless, this is how it can be done in Jira Cloud.

|--------------------------------------------------------------------------------------------------------------------------------|
| <https://community.atlassian.com/t5/Jira-questions/Smart-Values-not-working-as-expected-creator-displayName-and/qaq-p/2679352> |

comments: author: Elliott Lock
body: Hey thanks for the reply.

Regarding the version, perhaps we're not on cloud and I got that wrong. Assuming we're not might there be a better place to post my question?

That aside my UI looks a bit different to what you put in the link and this is what I keep finding. Here's an example of the UI:

![2024-07-12_11h50_27.png](https://community.atlassian.com/t5/image/serverpage/image-id/335258iA9B5CF5E07EEF49F/image-size/large?v=v2&px=999 "2024-07-12_11h50_27.png")

An example of the difference is I can't find any reference to "Smart value". From what I can tell this might be "Create variable"? But I'm unsure. Perhaps that helps with identifying how to do this within the version I'm on?


author: John Funk
body: Yeah, sounds like (and looks like) you are on DC. You can still post here, but when you post, let them know it is Data Center.

So, that means that some things will be different. Not sure of everything. In this case the Smart Values thing is the branch. You can probably get by with a different Branch type. Maybe use the JQL branch type for now and use the same JQL from the Scheduled JQL. Click off the Only include issues that have changed box.

But see if you can do all of the rest.


author: Levente R?ti
body: Hi [@Elliott Lock](/t5/user/viewprofilepage/user-id/405691) !  

I think it is possible using [Scriptrunner](https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=cloud&tab=overview) and [Email This Issue](https://marketplace.atlassian.com/apps/4977/email-this-issue?hosting=datacenter&tab=overview). This method would even allow you to customise your emails with custom CSS through Email This Issue.  
This [script](https://library.adaptavist.com/entity/send-release-notes-issue-stakeholders) does something similar to your use case(get all the issues), I will be happy to help you tailor it to your system.  
Also with ScriptRunner the automation part is handled too.  
Please let me know If I can help,  

Cheers,  
Levi


author: Carla Ann Rowland
body: [@Elliott Lock](/t5/user/viewprofilepage/user-id/405691) -- I haven't tested this but I used to do something similar on data center-- so broad strokes:

filter revision: project in ("super car") and fixversion in ("version 1.2.1") order by assignee

rule: yes keep it as scheduled and keep only include issues change since last run unchecked.

now having got this far-- do you have any additional add ons like script runner? if you don't you are going to have to "hard code branch" your rule or do an if then conditioning and filters for each member of the team involved in that version or write groovy script:

To do branch with sub-queries:

project in ("super car") and fixversion in ("version 1.2.1") and assignee = "TeamMember 1"

and action: send email with issue details you want to include

next level in branch--query=project in ("super car") and fixversion in ("version 1.2.1") and assignee = "TeamMember 2"

and action: send email with issue details you want to include . . . etc.

---

here is link if you need it on automation: [Jira Automation: How to Building New Rules and Top... - Atlassian Community](https://community.atlassian.com/t5/App-Central/Jira-Automation-How-to-Building-New-Rules-and-Top-5-Rules-Jira/ba-p/2469310)


Tags: automation

jira-data-center

jira-server