Hi Automation for Jira Experts,
A colleague of mine -- using the Jira API -- has created a number of future Sprints, setting the startDate and endDate.
Then, after an issue is added to a future Sprint, I want to set 2 custom fields -- PlannedStartDate and PlannedEndDate based upon the startDate and endDate of that future Sprint.
This is easy to do, when an issue is assigned to only 1 Sprint. However, occasionally some of our issues are associated with one or more previously closed Sprints (as the team didn't finish the work in the originally planned Sprint).
As an example, below is the JSON from such an issue:
"customfield_10006": [
{
"id": 2579,
"name": "AgileExample 149 (ends 7/27)",
"state": "future",
"boardId": 260,
"goal": "",
"startDate": "2021-01-01T00:00:00.000Z",
"endDate": "2021-01-02T00:00:00.000Z"
},
{
"id": 2246,
"name": "AgileTest 2",
"state": "closed",
"boardId": 260,
"goal": "",
"startDate": "2021-01-03T20:14:00.000Z",
"endDate": "2021-01-17T20:14:00.000Z",
"completeDate": "2021-01-26T18:38:47.127Z"
},
{
"id": 2278,
"name": "Snoopy 242 (ends 1/17)",
"state": "closed",
"boardId": 260,
"goal": "This is the sprint goal...",
"startDate": "2024-01-03T20:00:00.000Z",
"endDate": "2024-01-17T20:00:00.000Z",
"completeDate": "2021-01-30T00:23:16.746Z"
}
],
Things would be simple if the "future" sprint was always the first in the list (or the last in the list). As then I could use list.first or list.last function as described here <link>.
However, after some testing, I realized that there is no guarantee where the "future" Sprint will occur (and hence I don't know which element in the list to pull the startDate and endDate).
Question - Is there a way to "walk" the JSON object, looking for the startDate and endDate matching the element where state = "future"?
Thanks!
Doug