Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scripted custom field for Σ Remaining Estimate

Kelly LaMar December 26, 2018

Hi folks,

I need a scripted field that adds up the remaining time estimates of the subtasks. I know JIRA does this automatically on the parent issues but I need that "Σ remaining estimate" value in an explicit field so I can export those values to our project management tool. I have ScriptRunner, we're on the server.

I assume I'll then need to create a listener that triggers a re-index on the parent issue when subtasks are edited, but I can do that separately.

I'm not a developer and I can't figure out what specific script I need to make this work - any help would be greatly appreciated!

Thanks,

Kelly

2 answers

1 accepted

1 vote
Answer accepted
Kelly LaMar December 27, 2018

Thanks to Vasiliy Zverev I now have this script that does what I need - thanks for pointing me to those other threads!

import com.atlassian.jira.issue.Issue

long totalSum = 0;
for(Issue subtask: issue.getSubTaskObjects()){
if(subtask.getEstimate() != null)
totalSum += subtask.getEstimate()
}

return totalSum / 60
Kelly LaMar December 28, 2018

FWIW for future folks: I ended up tweaking the code so it now adds remaining estimates of all the subtasks as well as the remaining estimate on the story level ticket, or returns null if neither story nor subtasks have estimates. Final code below:

import com.atlassian.jira.issue.Issue

long totalSum = 0;
boolean noEstimates = true;
def totalSubTasks = issue.getSubTaskObjects().size()

for(Issue subtask: issue.getSubTaskObjects()){
if(subtask.getEstimate() != null){
totalSum += subtask.getEstimate()
noEstimates = false
}
}
if (issue.getEstimate() != null){
totalSum += issue.getEstimate()
noEstimates = false
}

if (noEstimates == true){
return null
}
else {
return totalSum / 60
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events