Hi Community
I need a little bit of help with a scripted field and looking for ways to limit the returned results to specific projects. My scriptrunner knowledge is very basic and have not been able to work this out.
Below is the code the script field - it simply returns the issue keys for specific link type (we have several script fields like this) and they're used for reporting. A team wants to limit the return values of specific projects only - so if one of their issues is linked to multiple projects that are linked via that type ; they only want to show the results for a specific project.
E.g. Issue ABC-123 is linked via 'delivers' type to DEF-456 ; XYZ-789 ; XYZ-890 but team only wants to know what XYZ issues are linked. The current script returns all delivers issues for ABC-123.
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.getOutwardLinks(issue.id)
def itr = links.iterator()
while (itr.hasNext()) {
def link = itr.next()
// Only care about "Delivered by" link types
if (link.issueLinkType.name != 'Delivers') {
continue
}
// Get other issue
def linkedIssue = link.destinationObject
// Line seperators if more than one ticket
if (retVal != '') {
retVal += '<br>'
}
retVal += "${linkedIssue.getKey()} "
}
return retVal
This script field was setup by a previous admin so unable to get assistance from them. I looked at scriptrunner documentation and seen you can add JQL queries but I don't understand the code enough to put that into my existing script fields.
I appreciate any assistance the community can offer.
Regards, Jamie