I'm looking to make a custom field with script runner to count the number of sub tasks that aren't closed.
I've been able to find a simple way of getting the number of sub tasks, but havn't been able to find a good library of functions that are available in the inline script editor.
issue.getSubTaskObjects().size()
obviously the simple solution would be to get the total count, then loop through the subtasks, subtracting from the original count for every one found to be in the closed state. I don't know if theres a simple one line solution though, such as issue.getSubTaskObjectsInStatus("closed").size() or something though. Can anyone help point me to a good library of available functions, or offer a quick solution?
This is what I've come up with so far
def subtasks = 0
for (i in issue.getSubTaskObjects()){
if (i.getStatus().getName() != "Closed")
subtasks += 1
}
return subtasks
Hi Connor,
here your code :
import java.util.Collection;
import com.atlassian.jira.issue.Issue;
Issue issue = issue;
Collection<Issue> subTasks = issue.getSubTaskObjects();
int count = 0;
for(Issue is : subTasks){
if(!is.getStatus().getName().equalsIgnoreCase("YOUR_STATUS_NAME_HERE"))
count++;
}
return count;
Hope this helps,
Ciao,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.