Hi Community
I need some further assistance with a scripted field which I don't think is working correctly - not sure what is wrong but hopefully someone can assist.
The purpose of the field is just to return the issue key for linked issues of a specific link type, and this has been narrow down to return results only from specific projects. It appears however for inwards links it is not returning correct results.
My example issue (EDE-119) has inward links to END-2346 (is related to) however my script below returns the issue's own key instead (EDE-119) which is not expected. It appears to return its own issue key as in another example there were 6 END issues linked via this type and the result was itself 6 times.
Something is definitely wrong somewhere but I am still learning and cannot figure it out.
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def cfManager = ComponentAccessor.getCustomFieldManager()
def retVal = ''
// Get only outward links
def links = issueLinkManager.getInwardLinks(issue.id)
def itr = links.iterator()
while (itr.hasNext()) {
def link = itr.next()
// Only care about "is related to" link types
if (link.issueLinkType.name != 'Relates') {
continue
}
// Only care about linked issue of given projects
def allowedProjects = ['EDE', 'END']
if (!allowedProjects.contains(link.destinationObject.projectObject.key)) {
continue
}
// Get other issue
def linkedIssue = link.destinationObject
// Line seperators if more than one ticket
if (retVal != '') {
retVal += '<br>'
}
retVal += "${linkedIssue.getKey()} "
}
return retVal
I appreciate any assistance that can be offered.
Regards, Jamie