Hi dear community,
I'd need your help to find an alternative solution to a scripted custom field (Epic Time Spent) that was implemented with the 3rd-party app ScriptRunner; we won't have this application available in our new Cloud environment.
This is the Groovy script that is currently used to calculate and display the total logged time of an Epic and all the issues within it (in hours): ⬇️
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
Issue epicIssue = issue
if (epicIssue.getIssueType().getName() != "Epic") {
return null
}
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
Long timeSpent = 0
if (epicIssue.getTimeSpent()) {
timeSpent = timeSpent + epicIssue.getTimeSpent()
}
epicIssue.getSubTaskObjects().each { subIssue ->
if (subIssue.getTimeSpent()) {
timeSpent = timeSpent + subIssue.getTimeSpent()
}
}
issueLinkManager.getOutwardLinks(epicIssue.getId()).each { epicLink ->
if (epicLink.getIssueLinkType().getName() == "Epic-Story Link") {
Issue epicLinkedIssue = epicLink.getDestinationObject()
if (epicLinkedIssue.getTimeSpent()) {
timeSpent = timeSpent + epicLinkedIssue.getTimeSpent()
epicLinkedIssue.getSubTaskObjects().each { subIssue ->
if (subIssue.getTimeSpent()) {
timeSpent = timeSpent + subIssue.getTimeSpent()
}
}
}
}
}
if (timeSpent == 0) {
timeSpent = null
}
return timeSpent
Are you aware of any native solutions we could use, instead?
Or maybe a new customisation using Automation for Jira / JMWE?
Appreciate any help! 🙏