Automation rule to Sum up total story points in an Initiative
Asked by Francis Calderisi:

Good afternoon :)

I have created an automation rule the looks up all the child issues of an Epic then totals up ({{lookupIssues.Story Points.sum}}) and stores the result in the Story Point field of said Epic.

Currently I am trying to do the same for an Initiative with no success. Same rule, same JQL to find child issues. When I check the Audit Log the "Lookup issues" step says "A search during custom value definition found no issues."

![Screenshot 2024-09-06 at 11.29.39?AM.png](/t5/image/serverpage/image-id/346019iBEF131FC654CB410/image-size/large?v=v2&px=999 "Screenshot 2024-09-06 at 11.29.39?AM.png")

When I run the JQL from the JQL query line I get 61 results.

I am having trouble understanding why this works for Epics but not Initiatives.

Any ideas or thoughts would be much appreciated. Thank you.

![Screenshot 2024-09-06 at 11.26.01?AM.png](/t5/image/serverpage/image-id/346021iAF7C5ABCED21464B/image-size/large?v=v2&px=999 "Screenshot 2024-09-06 at 11.26.01?AM.png")

![Screenshot 2024-09-06 at 11.28.21?AM.png](/t5/image/serverpage/image-id/346022i425421F2FC092441/image-size/large?v=v2&px=999 "Screenshot 2024-09-06 at 11.28.21?AM.png")


Answers:
author: Trudy Claspill
body: Hello [@Francis Calderisi](/t5/user/viewprofilepage/user-id/5586061)

Welcome to the Atlassian community.

Can you show us the results of the JQL query using the issue key shown in the log? I want to see the Issue Types for the issues in the results. The other information can be obscured.

comments: author: Francis Calderisi
body: Hi Trudy,

This is what I am getting...

![Screenshot 2024-09-09 at 11.17.49?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/346382i7983B72304FFEF85/image-size/large?v=v2&px=999 "Screenshot 2024-09-09 at 11.17.49?AM.png")

It is a mix of Story, Task, Bug and Epic issue type.  

Thank you


author: Trudy Claspill
body: Hello [@Francis Calderisi](/t5/user/viewprofilepage/user-id/5586061)

What is the Scope of the rule from the Rule Details page?

The Lookup Issues action is able to retrieve issues only from the projects that are listed in the rule Scope.

I notice that the issue that triggers the rule in in the RM project. In the image you provided from the Issues screen I see that the issues being retrieved are in other projects. In order for the Lookup Issues action to retrieve those issues you will have to make the rule a Multiple Project Scope rule and name each of the projects that might have an issue under the hierarchy of the RM issue. Or you can set the project Scope to Global to search all projects in Jira.

You might then want to add Conditions after your Trigger to ensure that the rule will continue only when the trigger is activated by changes in your intended source project vs. all the projects in scope.


author: Francis Calderisi
body: Thank you so much [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011), I was not aware of this...  

I will give it a try and see if this fixes my problem.

The other issue I imagine will sometimes come up is if their are more than 100 child issues. I saw in some documentation that the Lookup Issues can return "up to" 100 results.  

But first lets get some results :)   

Thanks again Trudy for the valuable insight.


author: Trudy Claspill
body: That is correct. That limitation is documented here:

<https://support.atlassian.com/cloud-automation/docs/automation-service-limits/>

One way to work around this would be to:

1. Update the sum stored in the initiative to 0 at the beginning of the rule. Then re-fetch the issue.

2. Use a Lookup Issues action that is more constrained; for example limit it to a particular issue type for the retrieved children. Find ways to constrain the results to less than 100 issues.

3. Edit the Initiative to add the sum from those issues to the current sum value (which is 0) in the initiative. Then re-fetch the issue.

4. Use another Lookup Issues action to get another set of issues, ensuring that the criteria does not overlap the first Lookup Issues action.

5. Edit the Initiative to add the sum from those issues to the current sum value (which is currently the sum from step 3) in the initiative. Then re-fetch the issue.

Repeat steps 4 and 5 until you have covered all possible child issues of the initiative.


author: John Funk
body: Hi Francis - Welcome to the Atlassian Community!

If you put the lookupIssues code into the Advanced search function and then use the value of the Initiative key - does it return anything?

In other words, execute this as a filter:

issue in portfolioChildIssuesOf("RM-263")

comments: author: Francis Calderisi
body: Good morning John,  

Yes, when I execute the JQL in the Advanced Search it returns 61 issues.

Which is why I am surprised that the lookup issues is giving me the message that no issues were found.


author: John Funk
body: Then it's probably related to the scope of the rule. Try changing it to a Global Rule and see if it returns issues in the lookup.


Tags: cloud

jira-cloud