Scriptrunner - Count linked unresolved issues

wvorigin June 18, 2018

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
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 18, 2018

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()
wvorigin June 18, 2018

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?

Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 18, 2018

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()
wvorigin June 19, 2018

Works!

Thank you very much

Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2018

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

jun lee January 31, 2023

@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?

0 votes
RJ March 9, 2022

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
AUG Leaders

Atlassian Community Events