Count of Linked issues in a custom field with respect to Link Type

Looking for a way to count of Linked issues in a custom field with respect to Link Type

2 answers

1 accepted

Accepted Answer
1 vote
Tarun Sapra Community Champion Aug 10, 2017

Without using plugins you can't do this in JIRA. You need scripted fields from the script runner plugin.

Some samples - https://scriptrunner.adaptavist.com/5.0.4/jira/scripted-fields.html 

At runtime when the screen loads you can calculate the linkedissues based on link type and show their count in the custom field.

I have not been able to find a way to do this using the documentation.  I did find this code and would like help altering it to specify a Link Type instead of an Issue Type:

import com.atlassian.jira.component.ComponentAccessor

 

int x = 0

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def linkedIssues = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, currentUser).getAllIssues()

if (linkedIssues.size() > 0){

  for (int i = 0; i < linkedIssues.size(); i++){

    if (linkedIssues[i].getIssueType().getName() == "Bug"){

      x = x + 1

    }

  }



if (x > 0){

  return x

}else return null

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

25,659 views 2 7
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