Automation For Jira - How to create a rule that sums up the story points from sub-tasks of a parent issue
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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 Automation Rules using the add-on Automation For Jira (for Jira Server/Data Center) meant to:
- calculate the sum of the Story Points field from all the sub-tasks of a parent issue (Story type issue, Task type issue, Bug type issue, etc...)
- copy that value to the Story Points field of the parent issue
Environment
Jira Server/Data Center 8.0.0 and above, along with Automation for Jira 7.4.0 and above.
Solution
Note that this implementation requires the configuration of 2 rules:
- 1st rule
- The purpose of this rule is to update the Story Points of the Parent issue as soon as the Story Points of one of its sub-task get updated, by executing the operation "Parent Issue Story points" = "Sum of Story points from all its child issues"
- 2nd rule
- The purpose of this rule is to handle the situation where a sub-task might be moved from one parent to another parent. In such case, the Story Points of the sub-task will be subtracted from the original parent, and added to the new parent
Configuration of the 1st rule
The rule will need to be configured as follows:
- Add the Field value changed trigger with the following settings
- Field to monitor: Story Points
- Add an Issue fields condition with the following settings:
- Field: Issue type
- Condition: Equal
- Value: Sub-task
- Add the following Branch rule
- Type of related issues: Parent
- Inside the Branch Rule, add the action below:
- Edit Issue
In the Choose field to set menu, select Story Points, and paste the expression below:
{{issue.subtasks.Story Points.sum}}
- Edit Issue
Screenshot of the 1st rule:
Configuration of the 2nd rule
- Add the Issue Updated trigger
- Add an Issue fields condition with the following settings:
- Field: Issue type
- Condition: Equals
- Value: Sub-task
- Add an Advanced compare condition with the following settings:
First value:
{{changelog.Parent Issue.FromString}}
- Condition: "Does not equal"
Second value:
{{changelog.Parent Issue.toString}}
- Add the following Branch rule
- Type of related issues: JQL
JQL: copy the query below:
key = "{{changelog.Parent Issue.FromString}}"
- Inside this Branch, add the Edit Issue action:
- Choose fields to set... :
- Select the Story Points field
Copy the expression below:
{{#=}}{{issue.Story Points}} - {{triggerIssue.Story Points}}{{/}}
- Choose fields to set... :
- Add the following Branch rule
- Type of related issues: JQL
JQL: copy the query below:
key = "{{changelog.Parent Issue.ToString}}"
- Inside this Branch, add the Edit Issue action:
- Choose fields to set... :
- Select the Story Points field
Copy the expression below:
{{#=}}{{issue.Story Points}} + {{triggerIssue.Story Points}}{{/}}
- Choose fields to set... :
Screenshot of the 2nd rule: