How can I display cumulative estimated time from subtasks in User stories?

Elise
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 20, 2019

Hello,

I have created a user story. Then I have created 2 tasks from this user story. I have specified estimated time for each tasks. My question is : Why the estimated time for my user story still blank? When I check the backlog view, the addition is not made! 

2 answers

1 accepted

0 votes
Answer accepted
Abhipsa Mohapatra August 20, 2019

@Elise 

You can achieve this by create a scripted field & add that script field on your parent story.

Inline Code: 

(This code is for linked issues. It can be modified for sub-task)

 

import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def totaloriginalEstimatedWork = 0

issueLinkManager.getOutwardLinks(issue.getId()).each() {l->
// log.debug(l.issueLinkType?.getName())
def linkedIssue = l.destinationObject
totaloriginalEstimatedWork += linkedIssue.originalEstimate ?: 0

}

def timeoriginalEstimatedWork = ""
if(totaloriginalEstimatedWork) {
def hours = totaloriginalEstimatedWork / 3600;
def minutes = (totaloriginalEstimatedWork % 3600) / 60;
def seconds = totaloriginalEstimatedWork % 60;
timeoriginalEstimatedWork = hours 

}
return timeoriginalEstimatedWork

0 votes
Abhipsa Mohapatra August 20, 2019

By using script field. I used this code for linked issues. You can modify as per your requirement(subtask).

 

import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def totaloriginalEstimatedWork = 0

issueLinkManager.getOutwardLinks(issue.getId()).each() {l->
// log.debug(l.issueLinkType?.getName())
def linkedIssue = l.destinationObject
totaloriginalEstimatedWork += linkedIssue.originalEstimate ?: 0
}

def timeoriginalEstimatedWork = ""
if(totaloriginalEstimatedWork) {
def hours = totaloriginalEstimatedWork / 3600;
def minutes = (totaloriginalEstimatedWork % 3600) / 60;
def seconds = totaloriginalEstimatedWork % 60;
timeoriginalEstimatedWork = hours 
// log.debug(timeoriginalEstimatedWork)
}
return timeoriginalEstimatedWork

Elise
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 20, 2019

Thanks we will test!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events