How to create a rule that sums up the the values from number custom field from Epic to a Parent issue

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This article describes how to create an Automation Rule to calculate the sum of the estimate values stored in the custom number field on the Epic issue type level and store the total value on the parent issue. We have many Branch automation rules to perform actions on related topics. However, the "Parent" branch does not work for issue type hierarchy above the "Epic." Unfortunately, the Jira Advanced Roadmaps fields are not fully supported in the Automation plugin, and it is impossible to iterate over the "Parent Link" field. We have an open feature tracking this requirement in the following issue: JIRAAUTOSERVER-135: Support "Parent Link" fields.

Requirement

In this example, we are using the following Issue Hierarchy:

  • Feature

    • Epic

      • Story

        • Sub-task

The field "Custom Estimate" exists for Epic and Feature issues. When the value of "Custom Estimate" changes on one Epic issue, the value should be recalculated, and the sum should be correctly updated on the Feature issue.

Solution

To work around the current limitation, we will utilize two actions:

  • Send Web Request - to perform JQL search over Jira Rest API

  • JQL Branch - to update the parent issue with the total summary.

Rule configuration

The rule will need to be configured as follows:

  • Add the Field value changed trigger with the following configuration

    • Field to monitor: "Custom Estimate"

  • Add an Issue field condition with the following configuration:

    • Field: Issue type

    • Condition: Equal

    • Value: Epic

  • Add the action Send Web Request with the following configuration:

    • Webhook URL: JIRA_BASE_URL/rest/api/2/search?jql=%22Parent%20Link%22={{issue.Parent Link}}

      • Replace JIRA_BASE_URL with the base URL of your Jira instance.

    • Headers:

      • Authorization header with Bearer token. For on details how to create a PAT token please refer to the following article: Using Personal Access Tokens.

    • HTTP Method: GET

    • Webhok Body: Empty

    • Wait for Response: Checked

  • Add Branch Rule with the following configuration:

    • Type of related issues: JQL

    • JQL: key = {{issue.Parent Link}}

    • Inside JQL Branch Rule Add Action Edit Issue with the following configuration:

      • In the Choose field to set menu, select "Custom Estimate", and paste the expression below, where customfield_xxxxx is the custom field id of the "Custom Estimate" field.

1 {{webhookResponse.body.issues.fields.customfield_xxxxx.sum}}

Screenshot showing the rule

Send Web Request Action:

Screenshot

Edit Issue Action:

screenshot

Jira Data Center - Rest API

To get started, read the reference documentation: Jira Server platform REST API] and Atlassian Developer - Rest API. The Jira Software and Jira Service Management applications have REST APIs for their application-specific features, like sprints (Jira Software) or customer requests (Jira Service Management). * Jira Software Server REST API * Jira Service Management Server REST API

Updated on November 4, 2024

Still need help?

The Atlassian Community is here for you.