I've recently found out about isSystemLink() method for links in ScriptRunner, while the documentation is lacking, the method seems to always return true for the children of an issue as seen in the code bellow, so Ive crafted this getChildren() nifty function that is very helpful to me in filtering other links and getting the children of any type of issue based on it
def getChildred(Issue issue) {
def outwardLinks = issueLinkManager.getOutwardLinks(issue.id)
def children = []
outwardLinks.each { child ->
if (child.isSystemLink()) {
children << child.getDestinationObject()
}
}
return children
}Extremely helpful!
Now that I found how to getChildren(), I should be able to also getParent(), by using the same logic in reverse, right? Wrong, for some reason the inwardLinks.isSystemLink() always seem to return itself instead of the parent link:

Thoughts on how to make getParent() return what I want? Scriptrunner has getParentObject() but it does not return Initiatives and I have to get the Parent Link and use hoops from there to get it when needed and also for Epics I have to use getEpic() instead of a single method that can be used anywhere, also for Stories its getStory() but it works only on the matching subtasks/tasks.
I need a singular function that would return the parent issue everywhere