Hi,
I'm looking for help with creating a custom field that pulls in the value of "Original Estimate" on any issue based on the Assignee and Sprint of that issue.
- This can't be user-specific as we need this for a large team.
- We can already pull the total from any Sub-tasks, just need to move that over to a custom field.
Ex. Johnny has a Capacity issue with a "Total Hours of Work" field that needs to pull in the total hours of all issues assigned to him during Sprint 1.
- There is 1 Story with 3 Sub-tasks under it, each with 3 hours on the original estimate and another Story with 8 hours on the original estimate.
- All issues are assigned to Johnny and Sprint 1.
So the "Total Hours of Work" field on the Capacity issues should 17 hours based on the original estimate from all issues combined.
Code to pull in the total hours of Sub-tasks and Story:
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 / 60
}
Any help is much appreciated!
Thanks,
Matt