Workarounds for Scheduled Notifications / Automation Batch Processing?
Asked by Evan Nixon:

Hello!

I'm currently attempting to create a notification which sends a direct Slack message/notification via a Webhook, based on certain conditions. The rule runs every weekday at 9am and 4pm, and follows this logic :

```
JQL : Are there tasks where the custom field "Waiting on Reply" is NOT EMPTY and hasn't been updated in more than 12 Hours??

? ? ?IF TRUE : Continue automation.

? ? ?IF FALSE : End automation.

BRANCH IF ELSE : Do any of the LookupResults "Waiting on Reply" field contain DisplayName "User 1"?

? ? ?IF TRUE : Send web request then continue to next BRANCH IF ELSE

? ? ?IF FALSE : Continue to next? BRANCH IF ELSE

BRANCH IF ELSE : Do any of the LookupResults "Waiting on Reply" field contain DisplayName "User 2"?

? ? ?IF TRUE : Send web request then continue to next BRANCH IF ELSE

? ? ?IF FALSE : Continue to next? BRANCH IF ELSE

(continues on repeating above BRANCH IF ELSE)
```

Everything is *almost* working as intended, however when the request is run it sends as many messages as match the JQL Search, when I really only want it to send one.

I did successfully get a user property set for four users using the [instructions here](https://community.atlassian.com/t5/Marketplace-Apps-Integrations/How-can-I-map-Jira-users-to-my-Slack-users-when-sending/qaq-p/1025383) and have the smart value {{issue.customfield_10632.get(0).properties.slack}} work as intended, however this didn't work out as I wanted due to {{lookupIssues}} not supporting custom fields.

I've done four separate branches of IF ELSE with the usernames manually input, which works for me considering there are only 4 users this needs to target (though a recursive option that changes the ".get("X")" each run until every user in the JQL lookup has received one notification would be nice).

Here's the automation rule as is. I did try and take the advice of the venerable [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) in [this thread](https://community.atlassian.com/t5/Jira-Software-questions/Not-able-to-find-the-option-Process-all-issues-produced-by-this/qaq-p/1749675#M150288), but didn't have any luck there either.

![Screenshot 2021-11-23 121555.png](https://community.atlassian.com/t5/image/serverpage/image-id/170571i47167EF5D999065B/image-size/large?v=v2&px=999 "Screenshot 2021-11-23 121555.png")

Which outputs this :

![Screenshot 2021-11-23 115533.png](https://community.atlassian.com/t5/image/serverpage/image-id/170573i69022AE6D8BFD315/image-size/large?v=v2&px=999 "Screenshot 2021-11-23 115533.png")

Any ideas on how I can get this to not run 4 times from 4 results being found in the JQL? Navibot should be annoying, but not quite *this* annoying.


Answers:
author: Bill Sheboy
body: Hi [@Evan Nixon](/t5/user/viewprofilepage/user-id/4514629)

You do not show your trigger's details, and I suspect that you have JQL in the trigger. Correct?

If so, that is why this is running for each issue found by the trigger. The way to address that is to remove the JQL from the trigger and just run it on the time interval. Then use a condition to check for issue matches on the JQL to halt/continue processing.

Kind regards,  
Bill

comments: author: Evan Nixon
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Thanks for your help on this, much appreciated as always.

I actually don't have any JQL set in the Scheduled Trigger. I did initially try it that way, which gave the same result : way too many notifications. The reason I have the JQL separated out was actually because of [your comment here](https://community.atlassian.com/t5/Jira-Software-questions/Re-Not-able-to-find-the-option-Process-all-issues-produ/qaq-p/1750200/comment-id/150288#M150288) on a thread about working around Jira Cloud not having a "Process all issues produced by this trigger in bulk" button - unfortunately that isn't seeming to work in this context.   
![Screenshot 2021-11-23 172902.png](https://community.atlassian.com/t5/image/serverpage/image-id/170651iA01D9EEDFDC36F98/image-size/large?v=v2&px=999 "Screenshot 2021-11-23 172902.png")


author: Bill Sheboy
body: Got it, and just to be clear: you are using Jira Cloud, correct?

If so, then try this:

* Take the JQL for your branch and instead use Lookup Issues with it
* Remove the branch
* Follow that with a if/else, and
  * Advanced compare condition on {{lookupIssues.size\|0}} greater than 0
  * Action to send the webrequest
  * Action to write to the audit log
* Repeat for your other branch...

That will allow you to execute the the if/else contents one-and-only-one time, yet have access to the specific issues using list functions on the {{llookupIssues}} result.


Tags: notification

schedule

slack

webhook