It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Sprint End date needed to be updated from last story in the sprint. Edited

I need to automatically update the Sprint end date .

 

The End date of the SPRINT should be the last STORY complete date in the sprint.

1. Any default option in jira ?

2. Any available option with script runner.

 

NEW CASE :

1,Epic end date should dynamically get updated based on story tagged to last created Sprint 

 

1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry Community Leader Sep 05, 2019

Hi @siva ,

See this script : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.status.category.StatusCategory
import java.sql.Timestamp;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

// the name of the issue link
final String issueLinkName = "Epic-Story Link"
def issueLinkManager = ComponentAccessor.issueLinkManager

def epicIssue = issueLinkManager.getInwardLinks(issue.id).find { it.issueLinkType.name == issueLinkName }?.sourceObject

//If the story is not attached to an Epic, do nothing
if (!epicIssue) {
return
}

// Find all the linked - with the "Epic-Story Link" link - issues that their status is not completed
def linkedIssues = issueLinkManager
.getOutwardLinks(epicIssue.id)
.findAll { it.issueLinkType.name == issueLinkName }
*.destinationObject?.findAll { StatusCategory.COMPLETE != it.status.statusCategory.key}

// If there are still open linked issues (except the one in transition) - then do nothing
if (linkedIssues.size > 0){
return
}

int dateFieldId = 11200
def dateField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(dateFieldId)
def dateFieldValue = epicIssue.getCustomFieldValue(dateField)

int sprintFieldId = 10100
def sprintField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(sprintFieldId)
def sprintFieldValue = issue.getCustomFieldValue(sprintField)?.endDate?.first()?.toDate()

if (sprintFieldValue){
dateField.updateValue(null, epicIssue, new ModifiedValue(dateFieldValue, new Timestamp(sprintFieldValue.getTime())), new DefaultIssueChangeHolder())
} else {
dateField.updateValue(null, epicIssue, new ModifiedValue(dateFieldValue, new Timestamp(new Date().getTime())), new DefaultIssueChangeHolder())
}

attach it to the last transition of the story workflow. It will update the end date value of the epic if all linked stories are in a green status. The end date value will either be : 

  • The end date of the sprint linked to the story
  • The transition date of the story if it has no sprint (or if there is no end date)

(Check your field ids beforehand)

Hope that is what you are asking for.

Antoine

Antoine Berry Community Leader Sep 06, 2019

Hi @siva ,

Did that work as intended ?

@Antoine Berry 

 

Tried a work aroud..!!

Mission Accomplished. :)

 

Thank u..!!

Antoine Berry Community Leader Sep 06, 2019

@siva You are very welcome ! 

Please mark this answer as accepted so it can help others in the future.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

342 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you