I have tried several different groovy script methods form various examples as I am not a coder, but have come close but no real success. I have thrown my hands up and am wondering if some smart person out there knows how to do this.
I simply need to show all total work logged for a specific link type of parent issues and their sub tasks to a single issue as a grand total. See diagram.
When you say groovy script methods it's a bit ambiguous what you are trying to do exactly, but, if I understood this right I've set it up with a Script Field which fingers crossed gets you closer.
This seems to work in my tests and I'm getting expected values on the Asset Record in your pic:
// Template: Duration (either of the 2)
import com.atlassian.jira.component.ComponentAccessor
def issueLinkmanager = ComponentAccessor.getIssueLinkManager()
def subtaskManager = ComponentAccessor.getSubTaskManager()
def workLogManager = ComponentAccessor.getWorklogManager()
def linkName = "Work"
def linkCollection = issueLinkmanager.getLinkCollectionOverrideSecurity(issue)
def linkedIssues = linkCollection?.getOutwardIssues(linkName) //Inward or Outward? Verify and change if needed.
if (!linkedIssues) {
// no linked issues
return null
}
def totalTimeSpentFromWorkLinkedIssuesAndTheirSubtasks = []
for (def linkedIssue:linkedIssues) {
def worklogList = workLogManager.getByIssue(linkedIssue)
for (def worklog:worklogList) {
def timeSpent = worklog.getTimeSpent()
totalTimeSpentFromWorkLinkedIssuesAndTheirSubtasks.add(timeSpent)
}
def subTasks = subtaskManager.getSubTaskObjects(linkedIssue)
for (def subTask:subTasks) {
def worklogListSubTask = workLogManager.getByIssue(subTask)
for (def worklogSubTask:worklogListSubTask) {
def timeSpent = worklogSubTask.getTimeSpent()
totalTimeSpentFromWorkLinkedIssuesAndTheirSubtasks.add(timeSpent)
}
}
}
return totalTimeSpentFromWorkLinkedIssuesAndTheirSubtasks?.sum()
You're a genius, that worked like a charm. No more head pounding. Thank you so much, here is a virtual beer on me!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.