It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can i get all of linked Issues in Listener?

I have added a listener, that changes the priority in related issues under certain conditions, 
but when I try to get list of related issues using this code:

def idOfMainIssue=event.issue.getId()
for(item in issueLinkManager.getOutwardLinks(idOfMainIssue)){

list only consists of 2 from 6 issues that i expected to get - one is a subtask and the other is related issue(one of 5)
Code works but from log.warn(issueLinkManager.getOutwardLinks(idOfMainIssue)) i know that it doesn't see more than 2 linked issues.

I'll appreciate any help

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.bc.issue.IssueService

def change = event?.changeLog?.getRelated('ChildChangeItem')?.any{ it.field=='priority' }

if (change &&"Zadanie") {
log.warn("Wejszłem do pętli")
def issueManager = ComponentAccessor.getIssueManager()
def issueBNGObj= issueManager.getIssueObject(event.issue.key)
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def idOfMainIssue=event.issue.getId()
for(item in issueLinkManager.getOutwardLinks(idOfMainIssue)){
def linkedIssue= item.destinationObject
def linkedIssueObj= issueManager.getIssueObject(linkedIssue.key)
def projName=linkedIssue.getProjectObject().name
String temp=linkedIssueObj.key

if(projName=="Rejestr Potrzeb"){
log.warn("Wejszłem do if RFC? w pętli")
issueManager.updateIssue(event.user, linkedIssueObj, EventDispatchOption.DO_NOT_DISPATCH, false)
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def validateAssignResult = issueService.validateAssign(user,, linkedIssueObj.reporterId)
issueService.assign(user, validateAssignResult)
log.warn("koniec ifa wewnątrz petli")


1 answer

1 accepted

0 votes
Answer accepted

If you want all links, you need both outward links and inward links. When configuring issue links as a Jira admin, you can define outward and inward descriptions.


Using the "Blocks" link type from my example, let's say I have the following issue link relationships configured:

  • TEST-1 - this is your main issue
    • Blocks (outward)
      • TEST-2
      • TEST-3
    • Is Blocked By (inward)
      • TEST-4
      • TEST-5
      • TEST-6

Using this line of your code assuming idOfMainIssue is the ID of TEST-1:


This will only return the links to TEST-2 and TEST-3. You will also need this line of code to get the inward links, as well:


You also make a note of Sub-Tasks in your problem description - in terms of Jira artifacts/objects, Sub-Tasks are treated differently and will not be retrieved using either of the methods above. You can just use this method instead to get a collection of the Issue objects that represent a given issue's Sub-Tasks:

def subtasks = issue.getSubTaskObjects() 

Thanks for Your help.

Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you