Sum of all story points for child issues in an epic when the epic is moved to Done

Carol Wesolowski March 26, 2024

I have looked through the automation references and other similar automation rules but cannot get my automation to work and would love some insight on what the problem is.

  • trigger: when an issue is move to Done
  • condition: issue type equals Epic
  • action: create a smart variable {{Sum}}
  • action: log Initialize {{Sum}} = 0
  • branch: to children
    • action: log lookup issues count: {{lookupIssues.size|0}}
    • action: log lookup issues SP sum {{lookupIssues.Story points.sum|0}}
    • action: log Issue key {{issue.key}}
    • action: log Issue Story Point {{issue.Story Points}}
    • action: {{Sum}} = {{Sum}} + {{issue.Story Points}}
    • action: SP Sum is {{Sum}}

Attached is the log debug statements.  Thanks in advance

Screenshot 2024-03-26 at 15.50.40.png

2 answers

2 accepted

1 vote
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 26, 2024

Hello @Carol Wesolowski 

Welcome to the Atlassian community.

Concerning this part of your rule:

  • branch: to children
    • action: log lookup issues count: {{lookupIssues.size|0}}

To use the {{lookupIssues}} smart value you must first have used a Lookup Issue action. I believe you should be using that action instead of the Branch For Children, in this case. The Branch For Children changes the focus of the rule activity from the parent Epic to the child issues, and would execute each action under the branch for each child.

Instead you should use the Lookup Issues action to execute a JQL that will retrieve all the child issues of the parent Epic that triggered the rule.

Then you get the sum of Story Points for all the issues returned in the Lookup Issues action with this smart value:
{{lookupIssues.Story points.sum|0}}

And you won't need to create or use a Variable at all.

 

  • trigger: when an issue is move to Done
  • condition: issue type equals Epic
  • action: Lookup Issues
    parent = {{triggerIssue.key}} and issuetype in standardIssueTypes()
  • action: log lookup issues count: {{lookupIssues.size|0}}
  • action: log lookup issues SP sum {{lookupIssues.Story points.sum|0}}
  • action: Edit Issue
    Set the field you're using in the Epic for the sum of the child issue story points
0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2024

Hi @Carol Wesolowski -- Welcome to the Atlassian Community!

Your rule can be simplified to use the Lookup Issues action with JQL to find the sum.  For example:

  • trigger: when transitioned to done
  • condition: issue type is Epic
  • action: lookup issues with JQL to gather the child issues for the epic
  • action: log, or use the sum as needed with {{lookupIssues.Story points.sum|0}}

 

The branching you show is not needed and will not work as I believe you expect:

Branches in rules which could be on more than one thing run in parallel and asynchronously, and so each item / loop runs independently.  This improves rule performance, although it requires we think differently about rule design as there is no guarantee of when the branch will finish, up until the last rule step, and nothing passes back out of the branch. 

There is no way to accumulate the results back out to a created variable outside of the branch or between each loop.

 

Kind regards,
Bill

Carol Wesolowski March 26, 2024

Thanks Bill,  I am having difficulty with the JQL query to lookup the child issues.

{{lookupIssues.IsChild}} does not work.  Help in formatting the query would be much appreciated.

Thanks!

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 26, 2024

Hello @Carol Wesolowski 

In the Lookup Issues action you need to provide a JQL statement to get the child issues of the Epic that triggered the rule. You use the same type of syntax you would using in the View All Issues screen, but in an Automation Rule you can use Smart Values to insert values from the issues in the rule.

So, to get the child issue of an Epic you would normally use:

parent=<Issue key of Epic>

In the rule you can reference the issue key of the Epic that triggered the rule in the JQL, as shown below

Screenshot 2024-03-26 at 11.51.56 PM.png

 

Then add an Edit action to edit the Epic and put into the field of your choice the sum of the story points from the issues found by the Lookup Action.

Screenshot 2024-03-26 at 11.52.58 PM.png

The "|0" in the smart value is to insert a value of 0 if the Lookup Issues action did not find any matching issues (children of the Epic that triggered the rule.)

Like Bill Sheboy likes this
Carol Wesolowski March 27, 2024

Trudy and Bill, thank you both for the help!  Automation is now working as intended.

 

~Best, Carol

Like Bill Sheboy likes this
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 27, 2024

That's great, Carol!

If our responses have helped you solve your requirement, please consider clicking on the Accept Answer button above the response thread(s). That will mark you Question as Solved, and help others searching the community find the posts with validated solutions.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events