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
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
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....!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not sure to understand, could you please specify the exact behaviour ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just answered on this specific question you asked a few days ago.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.
Register today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.