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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,410
Community Members
 
Community Events
177
Community Groups

Scriptrunner - Count linked unresolved issues

Dear Atlassian community,

 

I've build a counter with scriptrunner, with the following code:

 

import com.atlassian.jira.component.ComponentAccessor
ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter)
.getAllIssues().count {
it.getIssueType().getName() == "Incident"
}
.toString()

 

What this counter is doing it count all related issues with IssueType "Incident".

But how can I extend this that my counter only count the issues with issuetype "incident" that are unresolved? So with resolution = unresolved?

Thank you in advance if somebody can help

Best Regards,

 

2 answers

1 accepted

1 vote
Answer accepted

Hello @wvorigin

Like this :

import com.atlassian.jira.component.ComponentAccessor

ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter)
.getAllIssues().count {
it.getIssueType().getName() == "Incident" && issue.resolution == null
}
.toString()

Hello @Mark Markov,

Thank you for your reply.

The code is accepted, only it still count related issues that have a resolution as well.

So there is no different situation as my original counter.

Any other idea?

My bad, ive made mistake in condition, tryed to equals issue resolution instead of link issue :)

Here is right version

import com.atlassian.jira.component.ComponentAccessor

ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter)
.getAllIssues().count {
it.getIssueType().getName() == "Incident" && it.resolution == null
}
.toString()

Works!

Thank you very much

You re welcome! If it helps you please mark answer as accepted :)

@Mark Markov  

Hi,

I made a number type custom field named PlanPercent. I I would like to update the percentage value by counting the issues whose status of the linked issue type is Hierarchy link (WBSGantt) and whose status is Completed.  If issue A has 5 Hierarchy link (WBSGantt) linked issues, and 3 linked issues are Completed, percentage value must be 60. It is calculated by 3/5* 100.

 

Can you give me groovy script?

One question here

I am looking similar thing to have counter so any time issue gets related to other tickets counter field show number of tickets related on the ticket itself.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events