Send an e-mail to issue watchers when certain criteria is met
Asked by Artur Balyan _ Immedis:

Hello,

I want to send an email to people who have chosen to watch certain issues and to notify them when the issues reach a certain status.

I am using this structure:

![Screenshot 2024-07-09 144926.png](/t5/image/serverpage/image-id/334273iB114D4BEA1E39396/image-size/large?v=v2&px=999 "Screenshot 2024-07-09 144926.png")

I saw this from this article:

[https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#:\~:text=%7B%7Bissue.watchers.emailAddress%7D%7D%20%2D%20Returns%20the%20watcher%27s%20email%20address](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#:~:text=%7B%7Bissue.watchers.emailAddress%7D%7D%20%2D%20Returns%20the%20watcher%27s%20email%20address).

If this {{issue.watchers.emailAddress}} returns the watcher's email address shouldn't that rule send an email to all watchers by putting this smart value in the email address line. I also tried {{#issue.watchers.emailAddress}}{{/}}.

I get an error and no e-mails are sent over. The rule returns at least 1 item and I made sure that I am added as a watcher.

![Screenshot 2024-07-09 145739.png](/t5/image/serverpage/image-id/334277iC6F35ADE6C02CC76/image-size/large?v=v2&px=999 "Screenshot 2024-07-09 145739.png")

Any insight would be appreciated.

Thank you,

Artur


Answers:
author: Walter Buggenhout
body: Hi [@Artur Balyan _ Immedis](/t5/user/viewprofilepage/user-id/4510777),

You are using {{lookupIssues}} to retrieve multiple issues and then use {{issue.watchers.emailAddress}} as a smart value to retrieve the **To** email address(es), but you have not specified / initiated an issue in your rule. That is why there is no email address found.

You could retrieve a list of unique email addresses through a lookup Issues action and then add a branch to your rule *For each / Smart value*, sending the email to each email address.

As an alternative, if you could also use a filter subscription to send email notifications. That is a lot easier to use, does not impact your automation rule limit for your site, but has 2 limitations against your current approach:

* you cannot customise the email itself
* you would be sending the email to a fixed set of users

I suppose the amount of effort you should put into this relates to the desired outcome you're trying to achieve ...

Hope this helps!

comments: author: Artur Balyan _ Immedis
body: Hello Walter,

Thank you for the reply! I assumed that it would at least pick up one watcher and started to think that there is an issue with the smart value.

I'll try what you suggested with retrieving the email addresses.


author: bduncan
body: +1 Walter, branching should get you there to process through each returned issue.


author: Bill Sheboy
body: Hi [@Artur Balyan _ Immedis](/t5/user/viewprofilepage/user-id/4510777)

Adding to the other suggestions offered...

The watchers field is a **list** of users, and when this smart value expression is used in the Send Email action's To field:

```
{{issue.watchers.emailAddress}}
```

By default, it joins them with commas. However, the Send Email action uses a semicolon delimiter between email addresses. To solve this, please select that specifically with the [join()](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#list.join-separator-) function instead:

```
{{issue.watchers.emailAddress.join("; ")}}
```

Kind regards,  
Bill


Tags: cloud

cloud-automation

jira-cloud