I want to get the name of last sprint name created in board which is in open status for Automation
Asked by amehar:

I want to add the name of last created sprint in Summary of issue that will be created using Jira automation. A board has sequence of sprint names like Sprint 1, Sprint 2.... , I am creating a automation to create set of issues whenever new sprint is created. Board is having multiple sprints - 1 Active and many open sprint for future, I wanted to fetch the name of lastly created sprint so that I can add it in summary of issue,  
For Eg:   
Sprint 1 -Active  
Sprint 2 - Open  
Sprint 3 - Open  
Now when I am creating another Sprint in Board as Sprint 4- automation will create few predefined issues. In one issue I want to use name of last Sprint that was created in this Case "Sprint 3" in summary of issue.


Answers:
author: Rudy Holtkamp
body: Hi,

When you use the create sprint completed/created/started trigger you can use the {{sprint.name}} smart value.

comments: author: Rudy Holtkamp
body: Note if you have an issue of a previous sprint, you can use:

{{issue.sprint.name}}

To get the sprint name of that issue.


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

Adding to Rudy's suggestions...

You describe a rule which may look like this:

* trigger: Sprint created
* action: create issue
* action: create issue
* ...

As Rudy notes, for the [Sprint Created trigger](https://support.atlassian.com/cloud-automation/docs/jira-automation-triggers/#Sprint-created--started--or-completed), the **{{sprint}}** smart value is the one just created based upon the trigger. And so **{{sprint.name}}** may be used in the Summary when creating the issues.

Kind regards,  
Bill


author: amehar
body: Thanks for the answers. I am using the Sprint as trigger , Action as create issue , First issue is getting created and **{{sprint.name}}** is correctly fetched in summary.  
Now my problem statement is I want to use the name of last sprint that was created in the board in summary of the second issue to be created as create issue action in the rule. Please refer to the image below.  
**![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/333191iB218019BBC97BAEA/image-size/large?v=v2&px=999 "Capture.PNG")**


author: Bill Sheboy
body: If you mean getting *the sprint created immediately before the one in the trigger*, that is more difficult. Using some assumptions you might be able to reduce that difficulty...

If you assume there are issues assigned to that prior sprint, you could use the Lookup Issues action with JQL, and get an example issue's value for the sprint. The JQL could be:

```
project = yourProject AND sprint IS NOT EMPTY ORDER BY sprint DESC
```

And then the name you want would be:

```
{{lookupIssues.first.sprint.name}}
```

This works if that issue has one-and-only-one sprint assigned. Smart value, list filtering will be needed otherwise.

If there are no issues assigned to that prior sprint, you would need to call the REST API to get all sprints for the board, using the Send Web Request action. And then using a combination of created variables and smart value, list filtering, extract the name.


Tags: cloud

jira-cloud