Automation rule with emails for each user

Dennis_H
Contributor
December 28, 2023

I'd like to send an email daily that checks for issues that are older than 5 days and emails a list of the issues in that status to the reporter of the issue. So far I've managed to get a list emails but the users are getting an email for each issue that is older than 5 days. Ideally if they have 1 or 50 that are older than 5 days I'd like them to get one email instead of one for each issue. Also, if it only works if I have Run a JQL search and execute for each issue checked and the JQL I'm using for the next step in the scheduled step

 

Right now I have:

 

When:Scheduled

9:00 AM daily

JQL:project = "User issues" and status = "Issue set" and updated < -5d and "LTO [Checkboxes]" is EMPTY

Then: Lookup issues

JQL:project = "User issues" and status = "Issue set" and updated < -5d and "LTO [Checkboxes]" is EMPTY

And:Send Email

You have issues open longer than 5 days. Please check your issue requests and close any finished overrides. If you need to extend please check the LTO checkbox in the issue on the right column

{{#lookupIssues}}

* Issue Key: <b>{{key}}</b> (<a>{{url}}</a>)
* Summary: <a>{{Summary}}</a>
*Reporter: <b>{{issue.reporter.displayname}}</b>
{{/}}

 

The above works but all reporters get an email for each item that matches.

If I take the JQL out of step 1 then it fails

Would like to have it send one email per reporter if they have 1 or more issues.

2 answers

1 vote
Bill Sheboy
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 Leaders.
December 28, 2023

Hi @Dennis_H 

For scenarios when you want one email for something, try this without JQL in the scheduled trigger.  Instead, only use the Lookup Issues action to rollup the results.

And just to confirm: did you want to check for "in this status for more than 5 days" or "not updated in last 5 days".  If it is the first one...you may want to use the CHANGED JQL operator to focus on status values not changing, rather than just checking updated: https://support.atlassian.com/jira-software-cloud/docs/jql-operators/#CHANGED

For example, like below.  Please adjust to meet your specific case.

project = myProject
AND statusCategory = "In Progress"
AND NOT status CHANGED AFTER -5d
ORDER BY reporter

 

Putting that together with some rule adjustments like this:

  • trigger: scheduled with no JQL
  • action: lookup issues with the JQL
  • advanced compare condition: check if any issues were found by the lookup
  • advanced branch: on {{lookupIssues.reporter.distinct}}
    • action: lookup issues, with the same JQL plus filtered on the current loop value for the reporter
    • action: send the email with the issues from the lookup

Note this has a limit of 100 issues for automation rule actions.

Kind regards,
Bill 

0 votes
Dennis_H
Contributor
December 28, 2023

In the "To" field for the email I also tried:

{{lookupissues.reporter.displayName}} and got an error that the To field is empty. In the body of the email it displays the reporter when I use that exact same line

 

{{#lookupIssues}}

* Issue Key: <b>{{key}}</b> (<a>{{url}}</a>)
* Summary: <a>{{Summary}}</a>
* Reporter: <b>{{reporter.displayName}}</b>
*Email: <b>{{reporter.emailAddress}}</b>
{{/}}

Suggest an answer

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

Atlassian Community Events