I would like to get the latest destinationObject from the latest link between two issues, how am I supposed to do this? At the moment I'm getting the first element of the List but I'm not sure if the order of the list is that the latest link will be added to the first element of the List or I don't know. Should I just order it by issue id or issue key and get the latest one?
Issue links do not store any information about when or in what order the links were created.
They are displayed in the order specified by the jira.view.issue.links.sort.order property
So if you want to know the latest issues that was linked. That's not possible from the Issue Link panel in the UI or from the IssueLinkManager
You can try to look at the most recently created issue, but that may not be the most recently linked.
The only approach that may work requires consulting the ChangeHistoryManager.
A quick console script like this worked for me:
import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.issueManager.getIssueObject('JSP-1922')
def issueLinkManager = ComponentAccessor.issueLinkManager
def changeHistoryManager = ComponentAccessor.changeHistoryManager
def linkHistory = changeHistoryManager.getChangeItemsForField(issue, 'Link')
issueLinkManager.getLinkCollectionOverrideSecurity(issue).allIssues.sort{ link->
linkHistory.find{it.to == link.key }.created
}.last()
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.