Hey guys! I'm looking to create a scripted field to show only issues with the link type "is blocked by"
Ideally, it returns a click-able subset of the 'Links' column in the Issue Search that only contains links of the type "is blocked by".
I have a scripted field returning the superset of all issue links, but I'm not sure how to narrow it down. Any Help?
import com.atlassian.jira.component.ComponentAccessor
def ShowLinks = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter).getAllIssues()
ShowLinks
Thanks!
As you know, issueLink has a direction it goes, so issueLinkManager has methods to extract outward and inward links (getOutwardLinks(issueId) and getInwardLinks(issueId) respectively), I guess "is blocked by" is either inward or outward name of a link type which is called like "Blocks" or something.
so code might look like this:
import com.atlassian.jira.component.ComponentAccessor
ComponentAccessor.issueLinkManager.getInwardLinks(issue.id).findAll {
it.issueLinkType.inward == "is blocked by"
}*.destinationObject
you still need to play with either getting inward or outward links, filtering links by issueLinkType inward name, outward name, regular name or id (whichever you'd find better) and returning destinationObjects or sourceObjects of filtered links.
but the basic structure of code should look like this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a Similar requirement, were you able to solve the issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could try something like this:
import com.atlassian.jira.component.ComponentAccessor
def ShowLinks = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter)
ShowLinks.getInwardIssues('Blockers').collect{"""<a href="/browse/$it.key">$it.key</a> """}.join("<br>")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the tip on the ".collect()" I tacked that on the end of Ilya's help and it all works like a charm
import com.atlassian.jira.component.ComponentAccessor
def ShowLink = ComponentAccessor.issueLinkManager.getInwardLinks(issue.id).findAll {
it.issueLinkType.inward == "is blocked by"
}*.sourceObject.collect{"""<a href="/browse/$it.key">$it.key</a> """}.join("<br>")
ShowLink
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.