Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation Rule sends watchers email but also throws an error....

Sarah Bannon February 11, 2025

Hello,

I am creating a rule to send watchers of issues an email when the due date is approaching. I have used the template that available for use but altering it so that the watchers on issues get the email instead of the assignees.

I got the rule to run successfully yesterday and today I am have an issue when I run the rule that an error occurs in on of my lookup components.

Below I will attach images of the flow and where the error is. 

I don't understand how I am still getting the email but also an error.... Any help apricated.

Thanks 

3 answers

2 accepted

2 votes
Answer accepted
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.
February 11, 2025

Hi @Sarah Bannon 

The "watcher" field is the list of watcher users, and the plural "watchers" field is a count of the number of watchers.  Please update your JQL accordingly. 

Unfortunately, this is different than the rule's smart values, where {{issue.watchers}} is the list of users.

 

Next, when trying to branch over a list of users watching issues...within a list of issues from Lookup Issues, that is a list-of-lists, and so the distinct function will not work directly. 

Instead all of the values must be joined to eliminate the nested lists, and then finally the list may be split and distinct used.  For example:

  • action: create variable
    • name: varAllWatchers
    • value: {{#lookupIssues}}{{#watchers}}{{accountId}},{{/}}{{/}}
  • advanced branch:
    • name: varWatcher
    • value: {{varAllWatchers.substringBeforeLast(",").split(",").distinct}}
      • action: lookup issues, with JQL comparing watcher = "{{varWatcher}}"
      • ...

 

Kind regards,
Bill

Sarah Bannon February 12, 2025

Hello  @Bill Sheboy 

Thank you for your help here. I was unaware of the difference between the 'watcher' and 'watchers' fields.

 

My issue now is the email will not send. The error is ''Unable to send the email as the recipient's email address wasn't provided'' 

I have gone through an array of different values to try send the watcher email... not one has worked.

e.g. {{varWatcher.emailAddress}} ; {{varAllWatchers.emailaAddress}} ; {{lookupIssues.varWatchrer.emailAddress}} ' {{issue.varWatchrer.emailAddress}} and many more combinations and I am not sure where I am going wrong......

 

Any suggestions?

Thank you  ⁠

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.
February 12, 2025

Sorry, I forgot you also needed the email address! 

There are several ways to get that, but as we already had it with the watcher list, let's capture it for use later, building on what we started above.  As a slight change, we will store the watcher fields for accountId and emailAddress as JSON, allowing use of the jsonStringToObject() function later...and making testing easier.

 

  • action: create variable
    • name: varAllWatchers
    • value: 
{{#lookupIssues}}{{#watchers}}{ "accountId": "{{accountId}}", "emailAddress": "{{emailAddress}}" }~~{{/}}{{/}}
  • advanced branch:
    • name: varWatcher
    • value: {{varAllWatchers.substringBeforeLast("~~").split("~~").distinct}}
      • when the accountId is needed, use this: {{jsonStringToObject(varWatcher).accountId}}
      • when the emailAddress is needed, use this: {{jsonStringToObject(varWatcher).emailAddress}}
    • action: lookup issues, with JQL comparing watcher = "{{jsonStringToObject(varWatcher).accountId}}" and the rest of your JQL
    • ...

 

The update to the varAllWatchers variable uses "~~" as a delimiter now because we are using JSON with commas between the fields.  The final result would look like this when it has data:

{ "accountId": "12345", "emailAddress": "email for user 12345" }~~{ "accountId": "45678", "emailAddress": "email for user 45678" }~~

This makes parsing it easier as we can access each field with dot-notation in the same way as issue field, smart values.

Sarah Bannon February 13, 2025

Hello Bill,

Thank you so much for your help. I have got it to run successfully! 

The JQL I used in the last 'Lookup Issue' was the following:

 duedate = endOfDay({{dayOfIssue}}) AND statusCategory != done AND watcher = "{{jsonStringToObject(varWatcher).emailAddress}}" 

And then in the email field I used {{jsonStringToObject(varWatcher).emailAddress}}

I was actually still getting my original issue where I was getting the email but the flow was erroring. I managed to fix it by adding " " around the {{jsonStringToObject(varWatcher).emailAddress}} withing the last look up component. 

Screenshot 2025-02-13 105747.png

 

Anyways, it is working now with no issues! Thank you so much for your help :) 

Like Bill Sheboy likes this
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.
February 13, 2025

Awesome; I am glad to learn that helped.

 

For the JQL in the lookup checking the watcher, the account ID value would have worked with (or without) quotation marks rather than using the email address.

I didn't even know JQL could check watchers using the email address, so I learned something new.  Thanks!

Like Sarah Bannon likes this
Sarah Bannon February 21, 2025

Hello Bill, 

Sorry to follow up on this, but I have tried everything with no avail. now that the flow runs with no issues when there is a day that an issue is due i.e. a issue is due in 3 days time, but now i run into another error that the flow 'breaks' when there is no issue due, causing the flow owner to get an email about it... 

This is not a major issue as the flow will run the next day with no issue (if there is a ticket due) but the constant email that it failed is quite annoying. 

Do you have any suggestions?

Thank you Screenshot 2025-02-21 093239.png

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.
February 21, 2025

Hi @Sarah Bannon 

You want the rule to not send the email when there are no issues, and that may be done adding a condition after the first Lookup Issues action, checking the count (i.e., size of the list of issues):

  • smart values condition:
    • first value: {{lookupIssues.size}}
    • condition: greater than
    • second value: 0

 

Although from the audit log you show, it seems there were issues to process...or the an empty entry was processed by the advanced branch!

Would you please show an image of your current rule?  I am specifically interested in what is getting written to the log as that show nothing for the run on 18 February.

 

Sarah Bannon February 24, 2025

HI Bill, 

Yes, when there are no issues due, no email is to send. I tried this flow by using a 'branch rule' which gave me no error when there was no email due, but if there was multiple tickets a user is watching, they would get multiple induvial emails...

 

It is a scheduled rule and it runs every morning. Screenshot 2025-02-24 103733.pngScreenshot 2025-02-24 103838.png

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.
February 24, 2025

Please try adding that Smart Values Condition I described immediately after the first Lookup Issues action.  That will prevent the rule from proceeding when there are no issues.

Sarah Bannon March 12, 2025

Hello

 

I am only coming back to this issue we were having now

That worked.

 

Thank a mill 

Like Bill Sheboy likes this
0 votes
Answer accepted
Vishal Biyani
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.
February 11, 2025

@Sarah Bannon 

Please disregard my previous response. i was able to replicate your issue.

Below rule is working

snip.png

 

snip.png

Sarah Bannon February 11, 2025

Hi, 

Unfortunately that didn't work for me.... I am still getting the same error as I was before hand....

The issue seems to be that the watcher field not accepting the value, please see the image below

Screenshot 2025-02-11 194319.png

Vishal Biyani
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.
February 11, 2025

@Sarah Bannon 

That's because as @Bill Sheboy mentioned watchers is a count of number of watchers. 

You need to use watcher without s. 

of course, the automation needs to be enhanced incorporating Bill's suggestion

Sarah Bannon February 13, 2025

Thank you :) 

 

0 votes
Sarah Bannon February 11, 2025

Flow: Screenshot 2025-02-11 112203.pngScreenshot 2025-02-11 112434.pngScreenshot 2025-02-11 112511.png

Suggest an answer

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

Atlassian Community Events