Move parent to 'Done' when all child issues are closed
Goal | Automatically close a Parent issue when all of its Child issues are closed. |
---|---|
Scenario | You want to automatically close a Parent issue (e.g. Epic with Stories or Stories and Tasks with sub-tasks) when all of the child issues have been closed because all work for the Parent has been completed. |
Components | Event-based Action: Issue Transitioned, |
Baseline |
|
In these scenarios, some examples of the Parent-Child relationship are:
Jira Software “Parent/Sub-task”
Jira Software “Epic/Story”
Advanced Roadmaps (Portfolio) “Parent link”
Issues connected through the links available in “Issue Linking”
You are viewing the documentation for Jira Cloud.
Requirements
JIRA Administrator login
Workflow configuration
Only one transition is addressed in this Use Case - the transition from any status to Done; however, the same steps could be used on nearly any transition.
Nearly any scenario can be addressed where both:
The Parent issue status needs to match the status of the Child(ren) issue(s) AND
All Children issues have been transitioned to the destination issue (e.g. all children issues have been moved to Testing or moved to Client Review).
1. Create the Event-based Action
Log into your instance as an administrator.
Click on the Settings icon in the upper right corner.
Select Apps.
In the left-hand panel under JIRA MISC WORKFLOW EXTENSIONS, click Event-based actions and click Create new action in the upper right corner.
Give your Event-based action a name and, optionally, a description.
Under WHEN, make sure Select Event is selected. In the right-hand panel, select Issue Transitioned (Figure 1, right).
The Issue Transitioned configuration window will open (Figure 2, right). For To status, select Done and click Save.
Under IF SCOPE, select the projects and/or issue types that should trigger the Event-based option. If the post functions should be run for all projects and/or all issue types, leave the values as
Any
, as appropriate.
2. Add the Transition issue(s) post-function
Under THEN, click Select Post-functions.
In the right-hand panel, select Transition issue(s) in the list of post functions. The Transition issue(s) configuration screen will open.
For Target issues, select Parent issue of the current sub-task (Point 1, Figure 3, right).
Click the Transition Picker button to select a Transition (Point 2, Figure 3, right).
In the Pick a transition window:
Select your workflow from the Workflow name pulldown menu.
Select the transition for moving issues into the Done status.
Click Use transition name.
Click Expand all at the bottom right.
Check the box for Run this post-function only if a condition is verified.
In the script editor, enter the following (Point 3, Figure 3, right):
{% set subs = targetIssue | subtasks %} {% set trigger = true %} {% for sub in subs %} {% if sub.fields.status.name != "Done" %} {% set trigger = false %} {% endif %} {% endfor %} {{ trigger }}
Click Save to save your post function configuration (Point 4, Figure 3, right).
Save and Test the Action
In the main Event-based Action editor, click Save to complete the configuration. To test the new action, create a new issue with at least two sub-tasks. Then move the sub-tasks through your workflow until they are all in the Done status. Verify that JMWE moves the Parent issue to Done.
Congratulations!