Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

GroovyScript that saves the number of links of a JIRA into a custom field

Hey everyone, 

I need to show (on a dashboard) the number of links a JIRA has. I've looked into plugins (like SnapMetrics) but I believe the best way is to write a Groovy Script that essentially calls issue in linkedIssues([issueid]) and then stores the result in a custom field of the issue. I can then display the custom field on the dashboard. 

My coding is rusty, however, and I was wondering if anyone could point me in the right direction as to how I would go about this? 

Thanks in advance, 

Lee 

1 answer

0 votes

Assuming you have Scriptrunner - create a new scripted field, with a number searcher, and set for a numeric output.

Then the script you need can be condensed down to one active line:

return issueLinkManager.getLinkCollectionOverrideSecurity(issue).size()

Many thanks Nic, 

Do I need to import a specific com.atlassian class? I ask because I am receiving an error stating: 

groovy.lang.MissingPropertyException: No such property: issueLinkManager for class: Script44 at Script44.run(Script44.groovy:2)

Thanks again, 

Lee

Just to mention that I experimented with adding the following: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager

def issueLinkManager = ComponentAccessor.getIssueLinkManager() 

I'm not getting the error: 

groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.link.LinkCollectionImpl.size() is applicable for argument types: () values: [] Possible solutions: is(java.lang.Object), find(), sleep(long), find(groovy.lang.Closure), use([Ljava.lang.Object;), with(groovy.lang.Closure)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

278 views 16 17
Read article

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