Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Parent workflow transaction when Subtasks of a specific kind are closed

Hemanshu Sood
Contributor
September 16, 2018

Hi All,

 

I am looking for a scriplet to put in the workflow of a subtask :

There are 2 kinds of subtasks in my project ( X  and Y) 

In my Jira issue, there are 4 subtasks ( 2 of Type X and 2 of Type Y)

If all subtasks of Type X are Closed then parent should be moved to next stage. I am putting this condition in the workflow of Subtask of Type X, using the below condition, but it is not working:

issue.parentObject.subTaskObjects.findAll{it.issueTypeObject.name ="XXX"}.each{it.resolutionObject.name == "Closed"} 

The parent transition occurs even if I close a single subtask of Type XXX, while I want this check to be performed for all subtasks of Type XXX.

1 answer

1 accepted

0 votes
Answer accepted
Nir Haimov
Community Champion
September 16, 2018

Because you did not write any condition in your code...

it's just code that do nothing, that is why the transition happens even if only 1 subtasks is closed (and not all)

Use this:

def parent = issue.getParentObject()
def subtasks = parent.getSubTaskObjects()
def allSubtasksClosed = true;

for (def i = 0; i<subtasks.size(); i++) {
if (subtasks.getAt(i).issueTypeObject.name == "XXX") {
if (subtasks.getAt(i).getStatusObject().name != "Closed") {
allSubtasksClosed = false;
}
}
}
/*eventually if true (all subtasks of type xxx are closed) the parent will transition*/
return allSubtasksClosed

Suggest an answer

Log in or Sign up to answer