Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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

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

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

2 answers

1 accepted

0 votes
Answer accepted

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.

0 votes
Bloompeak Support Marketplace Partner Jun 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.

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
Site Admin
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,098 views 34 44
Read article

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