Get Issue Key of linked Issues

Hi All, 

Im having issues with getting the issue key of a linked issues:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.UpdateIssueRequest

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject('CB-7474')

IssueManager issueManager = ComponentAccessor.getIssueManager();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

def key = ComponentAccessor.issueLinkManager.getOutwardLinks(issue.getId())

return key



This is the code i have but it is returning an empty array?

Any help would be very much appreciated. 

 

Thanks!

Pon

1 answer

1 accepted

Hi Pon.

Taking a quick glance at your code I see that you are calling:

ComponentAccessor.IssueManager.getOutwardLinks(....)

But you have already accsed the issue manager before.

The modification should be in the last line as you can see here:

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject('CB-7474')

IssueManager issueManager = ComponentAccessor.getIssueManager();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

def key = issueLinkManager.getOutwardLinks(issue.getId())

return key

Hope this helps.

Cheers

Dyelamos

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

173 views 0 4
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