How to count the number of issue links of an inssue

Hi

I want to create a custom field to display the number of issue links of an issue. How should i do that ?

Thanks

6 answers

1 accepted

You can create a Script Runner Scripted Field.
The script for the field will look like:

import com.atlassian.jira.component.ComponentAccessor
a = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter).getAllIssues().size()
a.toString()

More info on scripted fields:

https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted+Fields

Thanks for your suggestion. I gave it a try but it does not work. Could you please help provide more detail steps ? Sorry i'm new to Jira

Which part did not work ?

Is the field shown with wrong value or it is not there at all ?

Hi Boris, I needed to count specific type of linked issues. Ex:- issue has 2 type of linked issues, 2 linked as blocks and 2 linked as clone. How can i get these separately. Current answer is 4, but i need 2

Variable [a] is undeclared is the error

Hi Thuy Mai,

Try Database Value plugin and select count(*) from issuelink whereSOURCE=(selectid fromjiraissue wherepkey='${jira.issue.key}')

or

https://answers.atlassian.com/questions/215718/scripted-field-to-return-number-of-cloned-issues-not-workingscripted field will help you most rather than DB value plugin.

I think its little bit closer to your requirement.

Cheers

Hi Thuy Mai,

Try Database Value plugin and select count(*) fromissuelink.

I think its little bit closer to your requirement.

Cheers

Hi Thuy Mai,

Try Database Value plugin and select count(*) fromissuelink.

I think its little bit closer to your requirement.

Cheers

It works now. Thanks

Worked with a slight modification of Boris script:

import com.atlassian.jira.component.ComponentAccessor
def CountLink = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter).getAllIssues().size()
CountLink.toString()

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

393 views 0 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you