Get linked issues by link name - Exalate Groovy

Hi all,
In the groovy script (I’m writing exalate script), how can I get the issue linked with an issue in a specific link name, just like when we are using the JQL function:

issue in linkedIssues("ITC-10", "causes")

In the picture below, I want to get the issue ITC-2.
image

Thank you!

Hi @nhac.tat.nguyen ,

I haven’t used this in a while but I’ll give it a shot :slight_smile: I believe issue has a field called issueLinks which contains an array of links or link objects. If you want to filter by link name, IssueLinks has a linkName field of type string or you can also use linkType if you want to filter by type just like in your JQL sample.

1 Like

Thanks a lot, @iragudo, you saved my day :wink:
The issue does have issueLinks:

issue.issueLinks.each{ link ->
    log.warn("Link Name: " + link.linkName + ", Issue ID: " + link.otherIssueId)
}
1 Like

Hi @iragudo, I should create a new thread for this question, but I think it will be fine if I ask here.’
Do you know how to do the same thing with ScriptRunner scripted field?
I have a Scripted Field, where I want to calculate the value from liked issues within type “causes”, but I can’t found any straightforward way to achieve that.

hi @nhac.tat.nguyen ,

Yeah, I think we should move this to a separate thread so that folks who are specifically interested on how to do this using ScriptRunner can easily find it :slight_smile:

While you haven’t created the new thread yet, I’ll post my answer here first (then move it later). I think the accepted answer here will help you iterate through the issue links, then you can filter out the relevant issue type/s for your calculation.

1 Like