Lookup issues looping Slack messages
Asked by Quinn Moffat:

Hello!  

I've got an automation from Jira.

The intention is that every time a deployment happens, the list of issues from the deployment get put into a slack message, and then sent to a slack channel.

What is currently happening is: we get N messages, with N issues in each message. If we've released 10 items in the release, we get 10 messages with all 10 issues listed in each.

What am I missing?

![Screen Shot 2022-06-03 at 4.14.39 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/200449iA3D6F4186618B222/image-size/large?v=v2&px=999 "Screen Shot 2022-06-03 at 4.14.39 PM.png")


Answers:
author: Simmo
body: [@Quinn Moffat](/t5/user/viewprofilepage/user-id/4957035)

Apologies that you've run into this, we really need to rename these actions as it is a bit deceptive. They should be called issue deployed successfully. The trigger runs once for each issue in a deployment.

This is why you are seeing this behaviour.

Cheers,

Simeon.

comments: author: Bill Sheboy
body: Hi [@Simmo](/t5/user/viewprofilepage/user-id/3608665)

Thanks for the information! From that trigger's smart values, it is possible to detect for which issue the rule is running? <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-development/>

If so, [@Quinn Moffat](/t5/user/viewprofilepage/user-id/4957035) could:

* sort the JQL with ORDER BY Key ASC to feed to the Lookup Issues action, and...
* add a condition to only proceed with sending the Slack message if the trigger issue is equal to the first one found in the lookup: {{lookupIssues.first.key}}

Kind regards,  
Bill


author: Simmo
body: Hey [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313),

I like it, thats some fancy thinking! I think so. {{issue}} should still work I believe so you can get the issue key that way!


author: Quinn Moffat
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) I've given this a go:  

I couldn't get the key within the conditional for whatever reason, so I've used the description field.

![Screen Shot 2022-06-07 at 11.07.42 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/200813i14F899418AFF6C97/image-size/large?v=v2&px=999 "Screen Shot 2022-06-07 at 11.07.42 AM.png")


author: Bill Sheboy
body: Nice! I am wondering why {{issue.key}} was not available for the comparison.

Got any ideas, [@Simmo](/t5/user/viewprofilepage/user-id/3608665) ?


author: Simmo
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) not in this case I'm afraid. It should be available or the rule would have errored. Would probably have to work backwards and start by adding a log component for {{issue}} and see what that gives, then go from there.


author: Bill Sheboy
body: Hi [@Quinn Moffat](/t5/user/viewprofilepage/user-id/4957035) -- Welcome to the Atlassian Community!

Your rule seems to match the same use case shown here for this trigger: <https://community.atlassian.com/t5/Automation-articles/New-Build-and-Deploy-triggers-for-Jira-automation/ba-p/1442789>

When you look at the audit log, does it show the rule being triggered multiple times for the same deploy?

Kind regards,  
Bill

comments: author: Quinn Moffat
body: Hey Bill! Correct. One deploy = N iterations,

where N is number of issues deployed