Counting Remote Issue Links

Vernon Lingley May 31, 2016

I am trying to create a custom field that counts the number of links to our external customer support system. I wrote the following off the the IssueLinkManager:

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def totalRemaining = 0
def externalLinkMatch = ~/SupportSystemName/
issueLinkManager.getIssueLinks(issue.id).each {issueLink ->
    if (issueLink.toString().matches(externalLinkMatch)) {
        totalRemaining += 1
 }
}

return totalRemaining as Double ?: null

However nothing is returning when I do this. Does the IssueLinkManager not access external links? If not what class and method(s) should I be using?

1 answer

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2016

You need a different interface:

com.atlassian.jira.issue.link.RemoteIssueLinkManager#getRemoteIssueLinksForIssue

Probably something like:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager

def remoteIssueLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager)
remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue).count {
    it.url =~ /SupportSystemName/
} ?: null
Vernon Lingley June 1, 2016

Perfect! Thank you. Yes, this interface has everything that I need. Now if I can just get the regex matching to work!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events