Calculate and display the total logged time under an Epic (Epic + Issues in Epic)

Giulia Caberlotto June 15, 2022

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! 🙏 

3 answers

1 accepted

0 votes
Answer accepted
Giulia Caberlotto June 22, 2022

Posting what I came up with to solve our use case (using only native functionalities + Automation for Jira), it might be useful for someone with a similar use case 🤞 

Epic time spent.png

The variable is not strictly needed to achieve this, but I'll have to expand the automation so I've left it there.

Mrudula.Madugu October 5, 2022

Hi

Thanks for the above rule, but this rule is not working when timelogged for subtask in the stories, Epic timelog is not updating. Do you have any suggestion here?

0 votes
Diana Belokon
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 6, 2022

Hi @Giulia Caberlotto 

I've noticed you are looking for a solution that doesn't need any expenses. Maybe you will be interested in out app Teamlead: EpicTime for Jira - SumUp of Worklogs.

It's free for teams that are up to ten users.

unnamed.png

EpicTime sums up work logs of child issues to the epic. Also, you can view the following information within Epic's issues:

  • Epic Estimate
  • Epic Time Spent
  • Epic Remaining
  • Epic Ratio (percentage of the spent time)

unnamed (1).png

A variety of reports provides data about time results for all epic issues.

0 votes
Bloompeak Support
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 16, 2022

Hi @Giulia Caberlotto ,

You can try Reports - Charts and Graphs for Jira app developed by our team to create various reports, charts and graphs for your Jira projects.

Here is a sample report that shows sum of time spent by epic.

Sum of Time Spent By Epic.png

  1. You first define your data source, it can be projects or custom JQL you type.
  2. Set Y-Axis, in your case Sum of Time Spent in hours
  3. Set X-Axis, in your case Epic. 

Below you can see an article about creating custom reports, charts and graphs in Jira with our app.

How to Create Custom and Flexible Reports, Charts and Graphs in Jira

Here is our live demo dashboard where you can see and modify sample reports and play with them.

Hope it helps.

Giulia Caberlotto June 16, 2022

Hi! Thanks for the suggestion.

We’re aware that this could be calculated via 3rd party apps like yours, however, this is not budgeted at the moment and we're looking for a different solution, as we'd also need to display the Epic Time Spent field within the epic. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events