Create review task for Project Lead

Goal

Create a review task automatically for specific types of issues, and assign it appropriately.

Goal

Create a review task automatically for specific types of issues, and assign it appropriately.

Scenario

For large development issues - in this scenario, issues that are Epics - automatically create a sub-task for the Project Lead to review the issue for completeness. Additionally, assign the new sub-task to the Project Lead. Lastly, the Approved by Lead field is required to transition the issue to In Progress.

Components

Create issue(s) post function, Field Required validator

Baseline

Note: the steps below demonstrate how to build a simple approval process for larger issue in the form of Epics. However, you could add this process to other issue types, including Stories and, for example, limit the required approval to only Stories with a certain number of sub-tasks (or however you determine issues requiring a large enough effort).

See the Alternate Configuration panels below for details on how to expand this Use Case.

Requirements

1. Custom field for Project Lead approval

Verify that your Jira instance has a custom field that can be used to designate that the Project Lead has approved the issue for development. If a field does not exist, create one and add it to the appropriate screens; see this page for more information: Create a custom field | Atlassian Support.

2. Add the Create issue(s) post-function

  1. Log in to your Jira instance as an Administrator.

  2. In the upper right corner of the window, click Settings ( ) and select Issues.

  3. In the left-hand sidebar, click Workflows.

  4. From the list of Workflows, click Actions ( ) for the appropriate workflow and select Edit.

  5. Switch to Diagram view if not already using it.

  6. Select the Create transition (Point 1, Figure 1, right).

  7. Click the Post Functions link (Point 2, Figure 1, right).

  8. Click Add post function at the top of the list of existing post functions.

  9. Select Create issue(s) from the list of post-functions and click Add at the bottom of the list.

Select Create transition and add post function
Figure 1 - Select transition

 

3. Configure the post-function

Note: Leave all fields to their default values unless specified below!

  1. For Issue type, select Sub-task (Point 1, Figure 2, right).

  2. For New value, enter the following script (Point 2, Figure 2, right):

    Project Lead Review - {{issue.fields.summary}}
  3. Click Advanced options.

  4. Check the box for Run this post-function only if a condition is verified.

  5. In the Write a script editor, enter the following script (Point 3, Figure 2, right):

    {{ issue.fields.issuetype.name == "Epic" }}
  6. Click Add (Point 4, Figure 2, right).

Create Issue(s) post function configuration screen
Figure 2 - Create issue(s)

 

4. Add the Field Required validator

Lastly, we need to add the Field Required validator to the transition between Backlog and In Progress to guarantee that large issues (Epics) have the custom field Approved by Lead checked before allowing the transition to complete.

  1. Back in your Workflow Editor, select the transition between Backlog and In Progress.

  2. Click Validators, and then click Add validator.

  3. Select Field Required Validator (JMWE app) and click Add at the bottom of the list.

  4. For Field(s), select Approved by Lead (Point 1, Figure 3, right).

  5. Enter an error message as needed (e.g. “'Approved by Lead' is required for large issues.”).

  6. Under Validator Scope, check the box for Conditional validation (Point 2, Figure 3, right).

  7. Enter the following script in Conditional validation expression (Point 3, Figure 3, right):

    !!issue.issueType && issue.issueType.name == "Epic"
  8. Click Add (Point 4, Figure 3, right).

Save and Test the Workflow

Save your Workflow and publish the changes. To test that the post function is configured correctly, create a new Epic issue and verify that the “Project Lead Review” sub-task was created correctly. Second, verify that the In Progress transition displays an error message when the Approved by Lead field is left unchecked.