Forums

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

Update EPIC (End date) , Depending on the completion date of the last story in the Epic.

siva
Contributor
September 4, 2019

I have a request  to update EPIC  (End date) , Depending on the completion date of the last story in the Epic.

 

Any post functions that could achieve this (or )  any script functions available.

Tried few postfunctions , but the requirements missing some criteria.

REF : ( Tried the below scrips but have some issues , my backgroud is not in to programming so any suggestions ??)

https://library.adaptavist.com/entity/close-an-epic-when-all-the-issues-under-that-epic-are-closd

+

https://library.adaptavist.com/entity/update-the-epic-link-for-an-issue-in-jira

 

(Note) :just need to merge both the scripts and the last  story should be considered.

 

Thank you

1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry
Community Champion
September 4, 2019

Hi @siva ,

I have tweaked a bit the adaptavist script, see below : 

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)
def currentDate = new Timestamp(new Date().getTime());

dateField.updateValue(null, epicIssue, new ModifiedValue(dateFieldValue, currentDate), new DefaultIssueChangeHolder())

Update the custom field id. Add this script in the story workflow, in the transition to the last status. 

This is based on the status category, if all the child stories are in a green status, then the date field will update on the epic.

Antoine

siva
Contributor
September 4, 2019

@Antoine Berry 

Thanks a lot Antoine ,

Checked the script , seems to do the job.

Need a little more R&D in Cloud instance will reach out for you in case i find any road blocks.

Cheers....!!

Like Antoine Berry likes this
siva
Contributor
September 5, 2019

@Antoine Berry 

We have another child request.

IT is to update the Sprint End date ( in which the story belongs)

to EPIC (( not just the story end date))

 

any extension of the code ??

Antoine Berry
Community Champion
September 5, 2019

I am not sure to understand, could you please specify the exact behaviour ?

siva
Contributor
September 5, 2019

@Antoine Berry 

 

When a story is completed in a sprint

EX: Sprint A ( startdate = 1st nov;;enddate= 10 nov)

 

The EPIC (END DATE) should be updated with the END DATE of the SPRINT A. (10 NOV)

( where the story is in the SPRINT A) 

Antoine Berry
Community Champion
September 5, 2019

I just answered on this specific question you asked a few days ago.

Like siva likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events