Aggregate times in custom fields

Anja February 19, 2015

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

1 vote
Dimitar Erinin October 21, 2019

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

0 votes
Anja May 4, 2015

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

0 votes
Anastasia Kozlova April 29, 2015

Hi @Anja,

This plugin may be useful for you.

0 votes
tvanbusk March 16, 2015

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

Suggest an answer

Log in or Sign up to answer