Wiki

Clone wiki

JIRA Workflow Toolbox / amazing / Close Parent when Subtasks are Closed

Automatically Close Parent Issue when all Subtasks are Closed

We want to automatically close parent issue when the all subtasks has been closed. We are going to describe two different solutions to implement this behavior:

Solution 1 - Using a validation about subtasks statuses in parent's workflow, and a post-function in subtask's workflow:


This solution consist on a validator in parent's workflow, and a post-function in subtasks workflow:

1) A validation in parent issue workflow to prevent parent issue from being closed manually whenever there still are open subtasks. To do it we use "Validation on subtasks" in transition "Done" or "Close Issue" on parent's workflow with the following configuration:


./amazing/close-parent-when-subtasks-closed/solution-1-validation-1.png
./amazing/close-parent-when-subtasks-closed/solution-1-validation-2.png

Once configured, transition "Close Issue" in subtask's workflow will look like this:
./amazing/close-parent-when-subtasks-closed/solution-1-validation-final-conf.png

Alternatively, we can use "Boolean validator with math, date-time or text-string terms" with the following boolean expression:

count(subtasks()) = count(filterByStatus(subtasks(), "Closed, Done"))


2) We add a post-function in subtask's workflow for trying to close parent issue each time a sub-task is closed. To implement it we use post-function "Copy a parsed text to a field" in transition "Done" or "Close Issue" on subtask's workflow with the following configuration:

./amazing/close-parent-when-subtasks-closed/solution-1-post-function-1.png

Once configured, transition "Done" or "Close Issue" in subtask's workflow will look like this:
./amazing/close-parent-when-subtasks-closed/solution-1-post-function-2.png

NOTE: Due to Issue #248, if you are using JIRA 7.0 or higher with versions of JIRA Workflow Toolbox older than 2.2.8, you should input the following boolean expression in parameter Conditional execution:

count(filterByStatus(siblingSubtasks(), "Closed, Done")) = count(siblingSubtasks())

This way we are preventing transition from being executed whenever the validation is not satisfied.


Solution 2 - Using only a post-function in subtasks workflow:

Solution 1 is usually preferred since it also prevents parent issue from being closed until all subtasks are closed, even if you try to do it by manually triggering transition "Done" or "Close Issue". Anyway, sometimes you may want to allow manually overriding parent closing, even if there still are open subtasks. Solution 2 is intended to be used in these cases:

This solution uses a post-function "Copy a parsed text to a field" in transition "Done" or "Close Issue" in subtask's workflow with the following configuration:

./amazing/close-parent-when-subtasks-closed/solution-2-post-function-1.png

Conditional execution: count(subtasks()) = count(filterByStatus(subtasks(), "Closed, Done"))


Once configured, transition "Close Issue" in subtask's workflow will look like this:

./amazing/close-parent-when-subtasks-closed/solution-2-post-function-2.png


Other Solutions:

Updated