First Blood notification
Asked by Max Twemlow:

Hi All

I would like JIRA to send an email notification which congratulates the assignee on being the first to transition an issue to Complete status for that sprint

i.e. if the issue is the first one with that status, then the assignee gets an email

Is this possible?

Thanks


Answers:
author: Darryl Lee
body: Hey [@Max Twemlow](/t5/user/viewprofilepage/user-id/5055008) - cool idea. I think I've got it, but haven't tested it.

Basically it triggers when an issue in the project (this is scoped for a single project) transitions to Closed.

It runs a **Lookup Issues** actions searching for any issues in the same sprint that are Closed. My thinking is that if there is only 1 result (so I check the {{lookupIssues.size}} value, then means you should be the first.

Give it a try, let me know if it works. :-}

![Screen Shot 2022-11-29 at 9.33.39 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/228251iF6162EBF12FBF4A7/image-size/large?v=v2&px=999 "Screen Shot 2022-11-29 at 9.33.39 PM.png")

comments: author: Darryl Lee
body: Ok, tested it and of course found a problem. {{triggerIssue.sprint}} needs to be in quotes, so the JQL should be:

```
sprint="{{triggerIssue.sprint}}" and status=Closed
```

I guess if the status you're looking for has two words, that should also be in quotes.


author: Bill Sheboy
body: Hi [@Max Twemlow](/t5/user/viewprofilepage/user-id/5055008) -- Welcome to the Atlassian Community!

That is an interesting idea for a *scrum team*...What about the unintended consequences of rewarding this behavior? Regardless...

Yes, and...to Darryl's suggestion:

It is possible that multiple issues could complete in a short window of time. Rather than check the Lookup Issues result for 1-and-only-1-issue, perhaps add to the JQL for the action ORDER BY Resolved ASC and then compare the trigger issue's key to {{lookupIssues.first.key}} and proceed if it matches the first one to resolution.

Kind regards,  
Bill


author: Darryl Lee
body: I'm so glad you found this ticket [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) because after I came up with my solution, I started thinking "Wait, is this a good idea?"

(I am totally an admin/implementation guy and unlike Bill have not spent ANY time doing actual Agile coaching/managing/etc. But still, after the technical challenge was finished, I did have some thoughts...)

Re: your other point, about multiple issues...  

I think it's highly unlikely that multiple issues would complete at \*EXACTLY\* the same time, since I'm triggering off of the transition to Complete. I suppose there might enough of a delay in *Automation processing* that multiple issues could be completed \*before\* the lookup action does it's search, so sure, your recommendation is a good idea \*IF\* people start noticing they didn't get their "First Blood" emails.  

(I'm not a very defensive programmer. More offensive. :-})


author: Max Twemlow
body: Thanks [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) I'll try it out

[@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) what unintended consequence were you thinking of?


author: Bill Sheboy
body: Hi, Max!

I was wondering about team interaction, trust, commitment, and focus for scrum...versus rewarding individuals completing things. This can be a balance, and for some teams rewarding individuals may lead people to focus on "my work" instead of the sprint goal and what the team is trying to achieve.

Thanks,  
Bill


author: Darryl Lee
body: Oh hey [@Max Twemlow](/t5/user/viewprofilepage/user-id/5055008) I was testing some other Automations, and they triggered an error from my First Blood automation because my new test issues did **not** have associated Sprints.

So you probably will want to add this right after the trigger:

**Issue fields condition:**

\> Field: Sprint  
\> Condition: is not empty


author: Max Twemlow
body: Thanks [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) will do

I'm also getting an access error when the sprint was made by my manager, however I'll be making all our sprints going forwards so shouldn't be a big issue:

*Custom Smart Value JQL Search: "(sprint="ADT-Q4-2022 : Sprint 4, ADT-Q4-2022 : Sprint 6" and status=Complete) AND (project in (12510))" - Sprint with name 'ADT-Q4-2022 : Sprint 4, ADT-Q4-2022 : Sprint 6' does not exist or you do not have permission to view it.*

It's weird because the error says I can't view the sprint, but I definitely can


author: Darryl Lee
body: Hi Max - for permissions, Automation by default runs with the "Automation User" as the Actor.

[What is a rule actor?](https://support.atlassian.com/cloud-automation/docs/what-is-a-rule-actor/)

So then, if you want the rule to run as yourself, with your permissions, you should change the actor to you. Here's the details on that:

[Run Jira rules as another user](https://support.atlassian.com/cloud-automation/docs/run-jira-rules-as-another-user/)

Hope this helps, and I'd appreciate it if you can click the \[Accept answer\] button up above. Thanks!


author: Max Twemlow
body: Good news, the team love it!