Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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()

Amazing, thank you :) 

Hi @Philippe Puy ,

I faced a problem for this script. Do you know how to count the number of linked issues base on linked issues type? Thank you very much!

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you