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!


Requirements

  • JIRA Administrator login

  • Jira Misc Workflow Extensions Cloud

  • The workflow status values for the initial status and final status of issues being transitioned together (e.g. BacklogIn 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:

  1. When a child issue is moved from BacklogIn Progress, if the parent issue does not already have a status of In Progress, the Parent will be transitioned.

  2. When a child issue is closed (e.g. moved from TestingDone), 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 TestingDone - but could also easily be applied to other transitions in the example workflow such as Client ReviewDone or TestingClient 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

A Jira Worflow Configuration
Figure 1 - Workflow Configuration

 

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:

  1. Select the transition that leads to the In Progress status and add a post-function:

    1. 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.

    2. 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.

  2. Select the https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242612 post-function from the list and click Add.

  3. Configure the post-function as follows:

  4. Target issue(s) - Select the appropriate relationship (Point 1, Figure 2, right). For example:

    1. Parent issue of the current sub-task to update a Parent issue when transitioning a sub-task

    2. Epic of the current issue to update an Epic when transitioning a Story

    3. Parent issue of the current issue in the Portfolio hierarchy when using Advance Roadmaps (Portfolio for Jira)

    4. Issues linked to the current issue through the following link type when using System links (Issue Linking)

  5. 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.

  6. Transitions - Select the transition that should be triggered for the target issue (Point 2, Figure 2, right).

    1. Select Trigger one of the following transitions.

    2. Use the Transition Picker to select the workflow and the transition that leads to the In Progress status of the Parent issue

  7. Run As - Leave this value as Current user unless you have a specific need.

  8. Transition screen - Configure these options as needed for your workflow.

  9. Conditional execution - Check the box for Run this post-function on if a condition is verified.

    1. 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.

  10. Delayed execution - Configure these options as needed for your workflow.

  11. Save the post-function.

  12. Move the post-function after the Update change history for an issue and store the issue in the database built-in post-function.

Figure 2 - Configure 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:

  1. Select the https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242612 post-function from the list and click Add.

  2. Configure the post-function as follows:

    1. Target issue(s) - Select the appropriate relationship (Point 1, Figure 3, right). For example:

      1. Parent issue of the current sub-task to update a Parent issue when transitioning a sub-task

      2. Epic of the current issue to update an Epic when transitioning a Story

      3. Parent issue of the current issue in the Portfolio hierarchy when using Advance Roadmaps (Portfolio for Jira)

      4. Issues linked to the current issue through the following link type and the link in "Issue Link" for System links (Issue Linking)

    2. 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.

    3. Transitions - Select the transition that should be triggered for the target issue (Point 2, Figure 3, right).

      1. Select Trigger one of the following transitions.

      2. Use the Transition Picker to select the workflow and the transition that leads to the Done status of the Parent issue

    4. Run As - Leave this value as Current user unless you have a specific need.

    5. Transition screen - Configure these options as needed for your workflow.

    6. Conditional execution - Check the box for Run this post-function on if a condition is verified.

      1. 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.

  3. Save the post-function.

  4. 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:

  1. Select the https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/466323193 from the list and click Add.

  2. Configure the condition as follows:

    1. Issue Link Type (Point 1, Figure 4, right):

      1. is Parent of for a Parent/Sub-task relationship.

      2. is Epic of for an Epic/Story relationship.

      3. Note: It is not possible to add this condition for Portfolio hierarchy relationships as Jira expressions do not support them.

      4. The appropriate link type for any other use of System links (Issue Linking).

  3. Mode - Select All issues must be in the selected statuses below (Point 2, Figure 4, right).

  4. Issue Type:

    1. Sub-task for a Parent/Sub-task relationship.

    2. Story for an Epic/Story relationship.

    3. Note: It is not possible to add this condition for Portfolio hierarchy relationships as Jira expressions do not support them.

    4. Any, or the appropriate issue type for any other use of System links (Issue Linking).

  5. Statuses - Select Done (Point 3, Figure 4, right).

  6. Save the condition.

  7. Publish the workflow.