It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Aggregate times in custom fields

Hi,

I'm using Script Runner to calculate the total estimate, remaining work and total time spent of all issues and subtasks related to an epic.

JQL is working fine 

issuefunction in subtasksOf("'Epic Link' = ABC-1") OR "Epic Link" = ABC-1 AND issueFunction in aggregateExpression("Total Estimate for all Issues", "originalEstimate.sum()", "Remaining Estimate for all Issues", "remainingEstimate.sum()", "Total Time spent", "timespent.sum()")

and results in an alert box when executing the search showing all my times.

Problem / Challenge:

I want to create 3 custom fields for all my epics dynamically calculating and showing the times for all issues and subtasks in it.

I'm looking forward to hints & tips! Thanks!

Anja

 

5 answers

Great question, if you figure it out I'd be interested in knowing as well!

Hi @Anja,

This plugin may be useful for you.

Hi @Anastasia Kozlova,

thanks for the hint and I would love to use it, but I'm not smart enough to figure out the Java code for my logic above smile I'm no developer.

Best, Anja

If you are already using ScriptRunner it would as easy as creating a scripted field with the script inside being something based on JQL search: 

https://scriptrunner.adaptavist.com/4.3.6/jira/recipes/misc/running-a-jql-query.html

this will get you the issues. 

Once you have the issues it is all about calculating the field you want to display. Something like this: 

def resultSum = 0

results.getIssues().each {epicIssue->

resultSum+=epicIssue.getOriginalEstimate()

}

return resultSum

 

change getOriginalEstimate() with getEstimate() and getTimeSpent() as needed

https://docs.atlassian.com/software/jira/docs/api/7.0.0/com/atlassian/jira/issue/Issue.html

 

also check out Adaptavist documentation on Scripted Fields: 

https://scriptrunner.adaptavist.com/5.0.4/jira/scripted-fields.html

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

881 views 7 24
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