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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

Hi Thuy Mai,

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

I think its little bit closer to your requirement.

Cheers

This widget could not be displayed.

Hi Thuy Mai,

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

I think its little bit closer to your requirement.

Cheers

This widget could not be displayed.

It works now. Thanks

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

91 views 1 0
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