Jira automation - Sorting issue by customfield into email and minifie info
Asked by Alexandre ANTOINE:

Hello

With Jira automation, I send an automatic release email when sprint are closed. And it's work. But I want to improve it

On this email, I want 2 things :

- have the list of all epic link (text custom field) in the sprint, but only minifie. For example, if I have 3 issues with epic link "test" and 4 with epic link "test2", I only want writing 1time "test" and 1time "test 2"

- can I sort the issue otherwise than by issue ID ?

I'm currently on server, but will migrate on cloud in 2 month (so a solution working for the 2, or, at least, for cloud version will be wonderfull

Best regards


Answers:
author: Bill Sheboy
body: Hi [@Alexandre ANTOINE](/t5/user/viewprofilepage/user-id/4648833)

I am using Jira Cloud, not Server/Data Center, so it would help me to see an image of your complete rule to offer suggestions. Would you please post that? Thanks!

Until then, I suspect you are using something like this as your rule:

* trigger: sprint completed
* branch: issues in the sprint (or with JQL) using the bulk-handling option
  * send your email

To do what you ask you would need two branches, one within another, and that is not possible with automation rules, or created variables, which are not in Server/Data Center version of automation. Once you switch to Cloud this will be easy to do with lookup issues and created variables.

Until you switch, one complicated work-around for Server/Data Center version would be to gather those epics using JQL (which will minimize the result to one entry per epic), and store the list in an entity property for the project. Then reference the entity property in the email.

Regarding your question about sorting by other than issue key, if your branch is based upon JQL you could pick your on ORDER BY clause.

Kind regards,  
Bill

comments: author: Alexandre ANTOINE
body: Hello Bill

Please find below my automation configuration. Email correctly sending since the beginin.

![2021-12-02_11h14_33.png](https://community.atlassian.com/t5/image/serverpage/image-id/171885i53C7A6AAADA21864/image-size/large?v=v2&px=999 "2021-12-02_11h14_33.png")

I try to use a #issue.customField_16304 to get the list of Epic (custom field 16304 give me the name of epic). But it's not working

I will try on my cloud test instance to create variable with lookupissue, maybe will I need some help

For the sort issue, how can I select the sprint I've closed with JQL ? (if I do "sprint in opensprint()", I get a blank email)

Thank a lot


author: Bill Sheboy
body: Thanks for that information. To respond to your specific notes:
> I try to use a #issue.customField_16304 to get the list of Epic (custom field 16304 give me the name of epic). But it's not working

For the branch you are using the *bulk-handling feature* in order to send one email and to get the smart value {{issues}} to work. (Note that one is plural.) You cannot reference {{issue}} in such a branch as singular.

If all of your issues have that custom field, you could reference the first one instead with:

```
{{issues.first.customField_16304}}
```

> For the sort issue, how can I select the sprint I've closed with JQL ? (if I do "sprint in opensprint()", I get a blank email)

From that trigger, the smart value is {{sprint}} and so your JQL to try would be:

```
project = myProjectName AND sprint IN ( {{sprint}} )
```