Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Populating the sprint field of a created issue depending on the due date

Guillaume Govers October 6, 2022

Hey Everyone,

 

I am working on a Jira Cloud instance, and I would like to be able to assign a Sprint to a created Epic automatically. This would be done by comparing the Due Date of the created Epic with the dates of active and future sprints. The correct Sprint will be chosen if the Due Date of the Epic is between the Start Date and End Date of the Sprint.

The Epic, when created, already has a Due Date. I want to avoid manually editing the Sprint field to fit the Due Date.

 

I have tried using both Jira Automation and JMWE to automate this but to no avail. I am unsure if there is a way to do this with these apps ?

 

Thank you for your help,

Jira JMWE.jpgJira Automation.jpg

2 answers

1 accepted

0 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.
October 6, 2022

Hi @Guillaume Govers -- Welcome to the Atlassian Community!

First thing, what problem are you trying to solve by doing this? 

I wonder because epics are typically not assigned to sprints as they are larger work items, taking multiple sprints to complete, and so their child issues are assigned to sprints.

Regarding your use case and question, this might be possible, by either...

  1. use a standard naming convention for sprints which is tightly coupled to date values, infer the specific target sprint by evaluating the issue's due date (through value date increments/adjustments) to dynamically build the sprint name, and then set the value
  2. call the REST API to gather all of the sprints for the project/board and use smart value, list filtering to find the sprint to use

Kind regards,
Bill

Guillaume Govers October 7, 2022

Hey @Bill Sheboy 

I appreciate that the way we use Epics is not the typical one. We are a non-dev team and an Epic is equal to an analysis that should be produced during a Sprint. This Epic has associated tasks (and not stories as seems to be the norm) that divide the work up. In the majority of the cases the Epic and related tasks will all be done in one sprint.

We have an integrated system where an external app automatically creates Epics with a populated Due Date. The idea is that instead of manually assigning these Epics to our Sprints this would be done automatically. 

 

1. Not sure I understand your suggestion. Would Sprint names look something like this?

"Sprint XXX: ##Start Date##;##End Date##" Sprint 34:22/08/22;10/09/22

Would I then use the Smart Values in Jira Automation to deduce the dates of a Spriint from its title ?

 

2. I have never used the REST API but have been wondering if this would be required here. Would you happen to have an example of a similar API that I could base myself on?

Thanks for your help,

Guillaume

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.
October 7, 2022

For method #1: yes, I was suggesting a structured sprint name that could be created only using the date (and not necessarily the number).  Let's say you pick an anchor starting date of 1 Jan 2022, and have 2 week sprints.  You should be able to determine the correct sprint based upon the due date by rounding up to the next whole 2 week increment.

For the REST API usage (for #1 or #2), here is a great how-to article showing how to call such methods: 

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

And the specific method you want is to get all the sprints for a board: 

https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-sprint-get

Guillaume Govers October 11, 2022

Hello, again @Bill Sheboy

I have managed to configure two web requests with the Rest API.

The first one is a GET that returns all the sprints of my board, as you suggested. 

The second one is a PUT that edits the sprint field of my trigger issue. 

These two seem to work fine after some back and forth.

However, I still can't seem to find a way to differentiate sprints depending on the due date of the trigger issue. I have tried using the Jira Automation conditions to no avail. I have also tried using the Due Date smart value in the JSON of the web request, but they do not seem compatible.

Follow UP Rest API.jpgTo my understanding, with the smart values, I should be able to access the start date of all sprints from my first web request and compare them to the due date. Or could I add an "if" function in the payload of my web request? It is still unclear to me how to achieve this distinction based on the due date.

Thank you for your help already, feeling quite proud to have used the REST API for the first time :)

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

I believe you can do this with smart value list filtering: https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

For your web request response to gather all of the sprints, use the issue's due date and find the one where the due date is within the sprint's data range.  Then use that sprint name (or id) as needed.

Guillaume Govers October 13, 2022

Hello @Bill Sheboy

Have been dabbling in this, however every time I seem to have a smart value filter that should work I seem to get this error message:

"Error invoking method com.codebarrel.automation.api.component.smartvalues.objectwrappers.CollectionWrapper.Element.get(java.lang.String@2061000330) on com.codebarrel.automation.api.component.smartvalues.objectwrappers.CollectionWrapper.Element@1007599544:"

I am not sure how to solve it. I have found some similar errors that seem related to the use of plug-ins. This does not seem to apply here as I am using only classic Jira fields ?

I would appreciate any insight you have here. Thank you for your help,

GuillaumeFollow Up Rest.jpg

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.
October 14, 2022

Perhaps the structure of the response does not match what you expect.  Please first try running that REST API request by just pasting the URL into a browser.  Then review the resulting response message to confirm you are getting the correct smart value layout.

 

UPDATE: After I experimented with this, I do not believe this can work with smart value, list filtering.  Sorry for the bad solution idea.

First, the endDate value from the response needs to be converted from Text to a Date type for comparisons, leading to an expression like this:

{{#webResponse.body.values}}{{#if(endDate.toDate.isAfter(issue.duedate))}}{{name}}:{{endDate}}{{/}}{{/}}

Unfortunately...issue fields (and created variables) cannot be used inside of a function, which is inside of an iterator.  Atlassian has already marked this defect as "Won't fix": https://codebarrel.atlassian.net/browse/AUT-2430

I also tried other functions instead of isAfter() and they were of no help.  The problem seems again related to trying to do this in the filter.

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 16, 2022

I don't think it is possible at the moment either @Bill Sheboy. I couldn't think of a way to do it. 

Like Bill Sheboy likes this
Guillaume Govers October 17, 2022

@Simmo @Bill Sheboy 

Thank you for your answers. I went with a simpler solution that requires the date of the next sprints to be added manually to the automation rule every few months. This won't be completely automatic but should work well enough for my use-case.

Thank you so much for your help and guidance,

Guillaume

Like Bill Sheboy likes this
0 votes
Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 6, 2022

Hi @Guillaume Govers,

What would be the event that would trigger the association between the epic and the sprint? 

Guillaume Govers October 7, 2022

Hello @Simmo the trigger would be the creation of the Epic with a populated Due Date field.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events