Automation Rule for Sum
Asked by Alexa Gutierrez:

I need help with an automation rule. I have two type of forms that each has Forecasted Hours as a field. I created a new field called Total Forecasted Hours for each as well. I am trying to set up the rule so for each issue submitted, it sums all the Forecasted Hours and shows it in the Total Forecasted Hours field. Here is the screenshot of what i have but is not working.![Forecasted hours.PNG](/t5/image/serverpage/image-id/317300i032F0371ADE8635F/image-size/large?v=v2&px=999 "Forecasted hours.PNG")


Answers:
author: Mark Segall
body: Hi [@Alexa Gutierrez](/t5/user/viewprofilepage/user-id/5472724) and welcome to the community!

I see the use of Lookup Issues and at a glance it doesn't look right because it should be driven by JQL. The smart value you have in there would likely be used on an Edit Issue action.

I'm not quite clear on your goal. You mention that you *"have two type of forms that each has Forecasted Hours as a field".* I'm unclear on this. Is it...

1. This is a **Jira form** (Jira Service Management) that is capturing Forecasted Hours several times   
   or
2. You have a number of **issues** that are capturing the Forecasted Hours and you wish to sum those up on the trigger issue that was just updated

If #1, you would not use Lookup Issues. I'd need more information on the form itself to gain better understanding of the problem you're trying to solve.

comments: author: Alexa Gutierrez
body: Hi mark,

Thank you for taking the time to review my question. My goal is to sum up hours from the field called "Forecasted Hours" and show the total sum in the field called "Total Forecasted Hours" in all issues but by form (Sorry if i am not using the correct terminology).

1. I have two forms created in Jira Work Management. One called Ideas and the other Hours. (Picture attached). They each have the field "Forecasted Hours". Everytime a user submits a form for either one, they have to fill out that field.  
2. I am trying to create a rule where it adds all the Forecasted hours for each form and shows the total in another field. (Third picture - This is an issue i open where you can see a field i created called "Total Forecasted Hours".


author: Alexa Gutierrez
body: ![Form Hours.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/317989iD78D7E72F62E7C20/image-size/large?v=v2&px=999 "Form Hours.PNG")![Form Ideas.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/317990i71C8494982CAFFA1/image-size/large?v=v2&px=999 "Form Ideas.PNG")![Issue Backend.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/317992i8554D672F9E1712E/image-size/large?v=v2&px=999 "Issue Backend.PNG")


author: Mark Segall
body: Thanks for the additional clarity. This helps me understand why you're trying to use Lookup Issues action.

So, we need a common thread here. I'm assuming "form" creates a new issue. And we need to understand how Jira is supposed to know which issues it needs to bring together to perform the sum calculation.

Most commonly, these issues should be linked in some way so that we can easily execute a query to find the related content. For example as the user submits the form, is it creating a sub-task on your main issue, creating a linked issue, using a common label, custom field, etc.?

Having that business logic to identify what issues are in play will help us in establishing the JQL that is required to execute the Lookup Issues action


author: Trudy Claspill
body: Hello [@Alexa Gutierrez](/t5/user/viewprofilepage/user-id/5472724)

Welcome to the Atlassian community.

Can you show us the details of each of those steps?

Can you show us what is in the Audit Log for the rule?

![Screenshot 2024-04-09 at 3.02.18?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/317324i8DEFCDB41F6A9B18/image-size/large?v=v2&px=999 "Screenshot 2024-04-09 at 3.02.18?PM.png")

If the rule has executed you should see an entry there with a status other than CONFIG CHANGE. Click on the "Show More" link next to the most recent entry that is newer than the last entry with a CONFIG CHANGE status, and share the details with us.

![Screenshot 2024-04-09 at 3.04.35?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/317325i648F05F40FFBD2CE/image-size/large?v=v2&px=999 "Screenshot 2024-04-09 at 3.04.35?PM.png")

How is the rule not working? What do you expect it to do? Do you expect it to update a field in the newly created issue? Based on what you have shown us there is no step to update any issues.

I think you are also using the Lookup Issues action incorrectly. Lookup Issues requires that you enter a JQL to use to select issues that you want to use in your rule. The results of the Lookup Issues action are stored in the {{lookupIssues}} smart value. It appears that you plugged in a smart value in that action where you needed to specify a JQL.

Can you perhaps provide some screen images of your form and issues and walk us through where values are entered and how you want the automation to update the issues?

comments: author: Alexa Gutierrez
body: Hi Trudy,

Thank you for taking the time to review my question. My goal is to sum up hours from the field called "Forecasted Hours" and show the total sum in the field called "Total Forecasted Hours" in all issues but by form (Sorry if i am not using the correct terminology).

1. I have two forms created in Jira Work Management. One called Ideas and the other Hours. (Picture attached). They each have the field "Forecasted Hours". Everytime a user submits a form for either one, they have to fill out that field.  
2. I am trying to create a rule where it adds all the Forecasted hours for each form and shows the total in another field. (Third picture - This is an issue i open where you can see a field i created called "Total Forecasted Hours".


author: Alexa Gutierrez
body: ![Form Hours.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/317986i7D6678118B4154D9/image-size/large?v=v2&px=999 "Form Hours.PNG")![Form Ideas.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/317987i8B08BBAAAA925FE2/image-size/large?v=v2&px=999 "Form Ideas.PNG")![Issue Backend.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/317988iFB68018D42DB1020/image-size/large?v=v2&px=999 "Issue Backend.PNG")


Tags: cloud