Forums

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

How to get name of newest sprint in ticket

Even May 9, 2022

I'm trying to create an automation that automatically assigns a fix version when a sprint is added to the ticket. 

This works fine until a ticket gets too many completed sprints. 

I have used this smart name to get the sprint name: {{issue.customfield_10113.last.name}}

When a ticket gets many completed sprints, they are sorted in a strange order, and I cannot find a way to change the sort order. (see order at the end).

The closest I get to grab the correct sprint is with this tag: {{issue.customfield_10113.id.max}}

But this of course only returns the id number, and I need the name. 

Any help is greatly appreciated! =) 

Here is the sprint order of one of the tickets. Grabbed from the api.

"customfield_10113": [
{
"id": 64,
"name": "LSCM Sprint W26",
"state": "closed",
"boardId": 22,
"goal": "",
"startDate": "2022-05-09T18:57:10.686Z",
"endDate": "2022-05-10T18:48:00.000Z",
"completeDate": "2022-05-09T18:57:27.036Z"
},
{
"id": 65,
"name": "LSCM Sprint W27",
"state": "future",
"boardId": 22
},
{
"id": 59,
"name": "LSCM Sprint W21",
"state": "closed",
"boardId": 22,
"goal": "",
"startDate": "2022-05-08T21:01:29.004Z",
"endDate": "2022-05-13T21:00:00.000Z",
"completeDate": "2022-05-08T21:02:28.391Z"
},
{
"id": 60,
"name": "LSCM Sprint W22",
"state": "closed",
"boardId": 22,
"goal": "",
"startDate": "2022-05-08T21:09:36.063Z",
"endDate": "2022-05-09T21:00:00.000Z",
"completeDate": "2022-05-08T21:09:48.775Z"
},
{
"id": 61,
"name": "LSCM Sprint W23",
"state": "closed",
"boardId": 22,
"goal": "",
"startDate": "2022-05-09T16:41:18.879Z",
"endDate": "2022-05-10T16:32:00.000Z",
"completeDate": "2022-05-09T16:41:37.706Z"
},
{
"id": 62,
"name": "LSCM Sprint W24",
"state": "closed",
"boardId": 22,
"goal": "",
"startDate": "2022-05-09T16:43:08.226Z",
"endDate": "2022-05-10T16:34:00.000Z",
"completeDate": "2022-05-09T16:43:45.034Z"
},
{
"id": 63,
"name": "LSCM Sprint W25",
"state": "closed",
"boardId": 22,
"goal": "",
"startDate": "2022-05-09T17:22:43.296Z",
"endDate": "2022-05-10T17:13:00.000Z",
"completeDate": "2022-05-09T17:54:23.926Z"
}
],

1 answer

1 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.
May 9, 2022

Hi @Even -- Welcome to the Atlassian Community!

This question comes up periodically, and the easiest answer is to use Sprint Names which always sort alphanumerically later when they occur later...Then your technique would work with {{issue.sprint.name.max}}

But if they do not...

First, and to save you some time, there is an awesome feature of smart value list filtering which seems like it would help...but the filter does not work with either created variables or nested smart values (lists within lists).

A complicated work-around that does work, and which will take a few seconds to run: 

Kind regards,
Bill

Even May 10, 2022

Hi Bill

Thanks for your reply! =) 

Naming them as numbers defeats the purpose, as it will make them difficult to understand. 

 

I looked into the smart value list filtering and hoped this would do the trick as a new variable. 

{{#if(equals(issue.customfield_10113.id, issue.customfield_10113.id.max))}} {{issue.customfield_10113.name}} {{/}}

But it returns the whole array of values and not the matching sprint. 

 

The API route is probably the way to go for now. I found an enhancement request to add sorting to this type of array, which will probably solve this sometime in the future. 

Thanks for your help! =)

br, Even

Even May 10, 2022

Got it working with the API 🤘

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.
May 11, 2022

Awesome!  The REST API can be used to solve several gaps/limits in automation...even if it is a bit slower for the rule.

I am still waiting to hear back from the Atlassian team if the smart value list filtering should work with smart value parameters.  If that ever works it will solve a lot of use cases.  Perhaps watch that thread to see if they respond to the open questions on filtering.

Have a good one!

Suggest an answer

Log in or Sign up to answer