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

5 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

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,321 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot