Summing values from a custom fields in a task into a custom field an Epic (JWM)
Asked by shelleyc:

I am trying to create an automation in a Jira Work Management Project that will add the value from the custom field in a task called "Invoiced Amount" which is "customfield_10156" and add to the custom field in the Epic called "Total Payments Received for FY" which is "customfield_10158" when the Task is transitioned from "Invoiced" (In Progress) to "Payment Received" (Done).

I was able to get the basic automation done but have had zero luck in getting it to sum the Invoiced Amount to the Total Payments received. My research tells me that you cannot sum custom fields like this via JQL and I am not familiar with Json and am basically stuck. I have done some research and believe that I need to send a Web Request, but could really use some help.

I am also having trouble getting it to select the issues in the Look Up without explicitly stating the parent ID. I figured that would be relatively easy once I figured out the summing part, but suggestions are welcome.

Also, I don't have a preference if it adds the invoiced amount of the card being transitioned to the Total or if it just takes all of the cards in the Invoiced Paid column related to the parent and sums them all up and overwrites the existing total.

![Jira_help1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/236890iB8A2FDA80498A2AD/image-size/large?v=v2&px=999 "Jira_help1.jpg")

Thanks in advance!

Shelley


Answers:
author: Bill Sheboy
body: Hi [@shelleyc](/t5/user/viewprofilepage/user-id/5131983) -- Welcome to the Atlassian Community!

In your lookup issues JQL that is inside of the branch, you may refer to parent = {{issue.key}} rather than the literal value. Inside of a branch, {{issue}} refers to the branched-to issue(s).

What is the purpose of your webrequest in the rule? If you just need the sum from the lookup you could do that with

```
{{lookupIssues.your field.sum|0}}
```

Kind regards,  
Bill

comments: author: shelleyc
body: I have tried every combination of {{lookupIssues.Invoiced Amount.sum\|0}} and {{lookupIssues.customfield_10156".sum\|0}} and neither of them have worked. It is like it is not recognizing that field at all.


author: Bill Sheboy
body: Smart values for fields are name, spacing, and case sensitive, so a small typo could lead to null results, and no error.

Let's try this: find an example issue with your field and then use this how-to article to confirm the exact name of your smart value. And...if you do not see the field, that tells you it is not supported by automation rule usage of the REST API. <https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>

Also...would you please show images of the details of your edit issue action and of the audit log details from the rule execution? Thanks!


author: shelleyc
body: I was finally able to get the correct combination! See my solution below:

![working_automation.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/237257i93CD224262D34D7B/image-size/large?v=v2&px=999 "working_automation.jpg")

My Edit Issue formula is: {{lookupIssues.customfield_10156.sum\|0}}.

Thank you for the help! This will make a huge difference in keeping track of invoices for a project I am managing.


author: wstromm
body: Hi, i can not get i work on datacenter. Is your automation running on cloud or datacenter version?

Thank you.


author: Bill Sheboy
body: Hi [@wstromm](/t5/user/viewprofilepage/user-id/5421008) -- Welcome to the Atlassian Community!

For Jira Data Center's version of automation, custom fields and many other fields are not yet supported for the Lookup Issues action. Please watch / vote for this suggestion to see progress on adding them: <https://jira.atlassian.com/browse/JIRAAUTOSERVER-877>

There are two possible workarounds, depending upon what you need to do:

* When you need to sum a field for a batch of issues only to send an email or message, use the bulk-handling feature of the scheduled issue trigger or branches: <https://confluence.atlassian.com/automation/run-a-rule-against-issues-in-bulk-993924653.html>
* When you need to edit an issue with the sum, use the Send Web Request action to call the REST API issue search with JQL, and then use the web response in the same way the lookup result would have been used. Here is a how-to for calling a REST API function from a rule: <https://community.atlassian.com/t5/Jira-Software-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828>

Kind regards,  
Bill


Tags: calculated-field

custom-field