Hi,
I am trying to create a custom field to show the count of a specific type of linked items.
Outward Description - PO & Inward Description - Purchases
I am returning 0 however there are 3 link of that type.
import com.atlassian.jira.component.ComponentAccessor def issueLinkManager = ComponentAccessor.getIssueLinkManager() def issueLinks = issueLinkManager.getInwardLinks(issue.getId()) def subElements = issueLinks.findAll { issueLinks*.issueLinkType.name.contains('Purchases') } return subElements.size() as Double
Any suggestions?
Use the actual link name, not the outward or inward description. You won't get both types because you are only looking at inward links. Then do again for outward links with the outward link name.
Example
Link name: Cloners (use this)
Outward: is cloned to
Inward: is cloned from
Thank you for your quick response.
I want to count the amount of Purchases the PO has. If I change it to the below I get 4, 1 cloner, 3 Purchases.
import com.atlassian.jira.component.ComponentAccessor def issueLinkManager = ComponentAccessor.getIssueLinkManager() def issueLinks = issueLinkManager.getInwardLinks(issue.getId()) def subElements = issueLinks.findAll { issueLinks*.issueLinkType.name.contains('Requisition') } return subElements.size() as Double
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok it is now showing the correct number but if i add in another 'Inward' link it adds them all together. It seems to be ignoring the name.contains().
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You want: issueLinks.findAll { it.issueLinkType.name.contains('Requisition') }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually it should be: issueLinks.findAll { it.issueLinkType.name == 'Requisition' }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @JamieA
I was searching for help here related to identify a "Cloners" link in a post function and nothing seems to work. I have seen multiple replies from you related to links in jira topics.
May I kindly ask you to take a look at this post, please? It should be simple but something I'm doing wrong
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.