Move Parent and Child Issues Together Through a Workflow
In this recipe, you will learn how to move parent issue and child issues together through a workflow. For example, you want to move a Parent issue to In Progress when work begins on any of its sub-tasks (the sub-task is moved to In Progress). Or you want to close an Epic when all of its Stories are closed (move to the Done status).
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 linked through the links available in “Issue Linking”
The steps below are written from the perspective of a single workflow for both Parent and Child issues, meaning the transitions and status names are the same. If you have separate workflows for these issue types, you will need to open the corresponding workflow (Parent or Child) before completing the steps within a section. Each section details which workflow needs to be edited.
In this example, the workflow is configured so that:
Issues that are being worked on currently have a status of In Progress.
Issues that have been completed have a status of Done.
In your Jira instance, the status values that represent these stages may be labeled differently, or you may have intermediate status values (such as QA Review between In Progress and Done). If you have different status values, or need to apply this behavior to different transitions, just substitute your status values in the steps below!
You are viewing the documentation for Jira Cloud.
On this page
Requirements
JIRA Administrator login
The workflow status values for the initial status and final status of issues being transitioned together (e.g. Backlog → In Progress or In Progress → Done)
Workflow configuration
Consider the workflow shown in Figure 1, right.
Following the steps below, you will create two JMWE post-functions that will move Parent-Child issues together as well as one Condition that will prevent the Parent issue from being closed prematurely. For the post-functions, we will address two different transitions:
When a child issue is moved from Backlog → In Progress, if the parent issue does not already have a status of In Progress, the Parent will be transitioned.
When a child issue is closed (e.g. moved from Testing → Done), the Parent issue will also be closed if all of the Parent’s sub-tasks are also closed.
For number 2 above, the steps describe a specific transition - from Testing → Done - but could also easily be applied to other transitions in the example workflow such as Client Review → Done or Testing → Client Review. Basically, any scenario where:
The Parent issue needs to match the status of the Child(ren) issue(s)
All Children issues have been transitioned to the destination issue (e.g. all children issues have been moved to Done or moved to Client Review).
1. Open the workflow
2. Add a Transition issue(s) post-function to the “In Progress” transition
Open the Child issue workflow using the steps in Section 1, above. Then follow these steps:
Select the transition that leads to the In Progress status and add a post-function:
When viewing the Workflow in Diagram view, select the Transition and click the Post Functions link. Click Add post function at the top of the list of existing post functions.
When viewing the Workflow in Text view, click the name of the Transition then select the Post Functions tab. Click Add post function at the top of the list of existing post functions.
Select the https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242612 post-function from the list and click Add.
Configure the post-function as follows:
Target issue(s) - Select the appropriate relationship (Point 1, Figure 2, right). For example:
Parent issue of the current sub-task
to update a Parent issue when transitioning a sub-taskEpic of the current issue
to update an Epic when transitioning a StoryParent issue of the current issue in the Portfolio hierarchy
when using Advance Roadmaps (Portfolio for Jira)Issues linked to the current issue through the following link type
when using System links (Issue Linking)
Issue Link - (Only available when Target issue(s) is set to
Issues linked to the current issue through the following link type
) - Set this to the link type that should be used to determine the target issue or issues to transition.Transitions - Select the transition that should be triggered for the target issue (Point 2, Figure 2, right).
Select
Trigger one of the following transitions
.Use the Transition Picker to select the workflow and the transition that leads to the In Progress status of the Parent issue
Run As - Leave this value as
Current user
unless you have a specific need.Transition screen - Configure these options as needed for your workflow.
Conditional execution - Check the box for
Run this post-function on if a condition is verified
.Enter the following code in the Condition field (Point 3, Figure 2, right):
{{ targetIssue.fields.status.name != "In Progress" }}
Where “In Progress” is the status to which the parent issue should be transitioned.
Delayed execution - Configure these options as needed for your workflow.
Save the post-function.
Move the post-function after the Update change history for an issue and store the issue in the database built-in post-function.
3. Add the Transition issue(s) post-function to the “Done” transition
In the Child issue workflow editor, select the transition that leads to the Done status and add a post-function using the steps in part 1, above. Then follow these steps:
Select the https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242612 post-function from the list and click Add.
Configure the post-function as follows:
Target issue(s) - Select the appropriate relationship (Point 1, Figure 3, right). For example:
Parent issue of the current sub-task
to update a Parent issue when transitioning a sub-taskEpic of the current issue
to update an Epic when transitioning a StoryParent issue of the current issue in the Portfolio hierarchy
when using Advance Roadmaps (Portfolio for Jira)Issues linked to the current issue through the following link type
and the link in "Issue Link" for System links (Issue Linking)
Issue Link - (Only available when Target issue(s) is set to
Issues linked to the current issue through the following link type
) - Set this to the link type that should be used to determine the target issue or issues to transition.Transitions - Select the transition that should be triggered for the target issue (Point 2, Figure 3, right).
Select
Trigger one of the following transitions
.Use the Transition Picker to select the workflow and the transition that leads to the Done status of the Parent issue
Run As - Leave this value as
Current user
unless you have a specific need.Transition screen - Configure these options as needed for your workflow.
Conditional execution - Check the box for
Run this post-function on if a condition is verified
.Enter the following code in the Condition field (Point 3, Figure 3, right):
{% set stories = targetIssue | subtasks %} {% set trigger = true %} {% for story in stories %} {% if story.fields.status.name != "Done" %} {% set trigger = false %} {% endif %} {% endfor %} {{ trigger }}
Where “Done” is the status to which the parent issue should be transitioned.
Save the post-function.
Move the post-function after the Update change history for an issue and store the issue in the database built-in post-function.
4. Enable transition to “Done” only when all sub-tasks are “Done”
In the Parent workflow editor, select the transition that leads to the Done status and add a Condition. Then follow these steps:
Select the https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/466323193 from the list and click Add.
Configure the condition as follows:
Issue Link Type (Point 1, Figure 4, right):
is Parent of
for a Parent/Sub-task relationship.is Epic of
for an Epic/Story relationship.Note: It is not possible to add this condition for Portfolio hierarchy relationships as Jira expressions do not support them.
The appropriate link type for any other use of System links (Issue Linking).
Mode - Select
All issues must be in the selected statuses below
(Point 2, Figure 4, right).Issue Type:
Sub-task
for a Parent/Sub-task relationship.Story
for an Epic/Story relationship.Note: It is not possible to add this condition for Portfolio hierarchy relationships as Jira expressions do not support them.
Any
, or the appropriate issue type for any other use of System links (Issue Linking).
Statuses - Select
Done
(Point 3, Figure 4, right).Save the condition.
Publish the workflow.