Cannot extract IssueLink from issue


I have 2 Jira instances (01 & 02) which are linked. Each instance contains an issue (TEST01-1 & TEST02-1). The issues are linked to each other (reciprocal link). My goal is to extract TEST01-1 from the link in TEST02-1, therefore I have written the following code:


import com.atlassian.jira.issue.Issue

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Category

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def allRelatedIssues = new LinkedList<Issue>()
for (IssueLink link in issueLinkManager.getOutwardLinks((Long)10400)) {

log.debug ('Size of Issue-List: ' + allRelatedIssues.size())
log.debug ('Content of Isse-List: ' + allRelatedIssues)
log.debug ('Size of IssueLink-List Outward: ' + issueLinkManager.getOutwardLinks((Long)10400).size())
log.debug ('Size of IssueLink-List Inward: ' + issueLinkManager.getInwardLinks((Long)10400).size())
log.debug ('Issue-Key for the Issue-ID 10400: ' + ComponentAccessor.issueManager.getIssueObject(10400 as long))

When I execute the code in the Script console I obtain the following output:

2017-11-10 15:51:29,780 DEBUG [groovy.PostFunction]: Size of Issue-List: 0
2017-11-10 15:51:29,780 DEBUG [groovy.PostFunction]: Content of Isse-List: []
2017-11-10 15:51:29,780 DEBUG [groovy.PostFunction]: Size of IssueLink-List Outward: 0
2017-11-10 15:51:29,780 DEBUG [groovy.PostFunction]: Size of IssueLink-List Inward: 0
2017-11-10 15:51:29,781 DEBUG [groovy.PostFunction]: Issue-Key for the Issue-ID 10400: TEST01-1


As the output indicates, the List "allRelatedIssues" is empty and I don't understand why. After all, the Issues are linked, I used the right Issue-ID (see Screenshots) and I performed a re-index just in case. What could be the problem? Does anybody have an idea?


Thank you in advance!



1 answer

1 accepted

2 votes
Accepted answer

It seems you have "remote links" in your issues instead of normal issueLinks. Thus "issueLinkManager" won't work as it's for internal links within the same JIRA instance but you have 2 different JIRA instances.

Try this code snippet

RemoteIssueLinkService remoteIssueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService.class)
RemoteIssueLinkService.RemoteIssueLinkListResult links = remoteIssueLinkService.getRemoteIssueLinksForIssue(currentUser, issue

 (you have to use "RemoteIssueLinkService") 

Hi Tarun,

thank you very much for your quick respond. You are right - that was the problem - now it's solved! :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,100 views 4 9
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