Hi,
I'm creating a scripted field in JIRA which will calculate the total of the time spent of the linked issues (LinkType = 'Test')
However i'm new in JIRA and scripted fields and I'm struggling with some issues.
I've written the following script but when I call the line below, i always get null back. Also when I change this to GetSummary or something else. I always get null
def timespent = linkedIssue.getTimeSpent()
import com.atlassian.jira.ComponentManager def componentManager = ComponentManager.getInstance() def issueLinkManager = componentManager.getIssueLinkManager() def totalSpent = 0D issueLinkManager.getInwardLinks(issue.id).each {issueLink -> if (issueLink.issueLinkType.name == "Test") { def linkedIssue = issueLink.getDestinationObject() def timespent = linkedIssue.getTimeSpent() if (timespent){ totalSpent = totalSpent + timespent } } } return totalSpent ? componentManager.getJiraDurationUtils().getFormattedDuration(totalSpent ) : null
Am I doing something wrong ?
Kind regards
Rob
Community moderators have prevented the ability to post new answers.
Hi Rob,
issueLinkManager.getInwardLinks(issue.id)
give to you links TO your issue (let's call it 'first') and the line
def linkedIssue = issueLink.getDestinationObject()
will give you for all the incoming issues the destination, which is always the 'first' issue. If I understand well you want the total time spent for the linked issues, therefore you should get the source issues
def linkedIssue = issueLink.getSourceObject()
PS. It is also better to use ComponentAccessor to get the issueLinkManager and the jiraDurationUtils (ComponentManager is getting deprecated)
import com.atlassian.jira.component.ComponentAccessor def issueLinkManager = ComponentAccessor.getIssueLinkManager() def jiraUtils = ComponentAccessor.getJiraDurationUtils()
Please let me know if this helps
Try using
issueLinkManager.getOutwardLinks(issue.id)
instead
issueLinkManager.getInwardLinks(issue.id)
maybe you need links from an issue, but not links to an issue.
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.