Missed Team ’24? Catch up on announcements here.

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

Count number of Resolved Subtasks

Miroslav Brabenec August 5, 2015

I am trying to count Resolved Subtasks:

import com.atlassian.jira.issue.Issue
Collection<Issue> subTasks = issue.getSubTaskObjects();
int count = 0;
for (Issue i : subTasks) {
    if (i.getStatus().toString()=="Resolved")
      count++
      return count.toString()
}

But it return 0. Where is the problem?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
JamieA
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.
August 5, 2015
issue.subTaskObjects.count { it.statusObject.name == "Resolved" }
Miroslav Brabenec August 7, 2015

Thanks, it works great.

0 votes
Alejo Villarrubia [Adaptavist]
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.
August 5, 2015

Where are you trying to use this code? In a scripted field?

0 votes
Volodymyr Krupach
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.
August 5, 2015

Your code returns on first iteration of the loop. I guess you need to move return out of the loop:

for (Issue i : subTasks) {
    if (i.getStatus().toString()=="Resolved")
      count++
}
return count.toString()
Miroslav Brabenec August 5, 2015

Thanks, but there is still the same problem. It returns 0. I do not know, whether condition if (i.getStatus().toString()=="Resolved") is correct.

TAGS
AUG Leaders

Atlassian Community Events