Counting Remote Issue Links

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

This widget could not be displayed.

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

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published yesterday in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

148 views 0 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you