Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Sum numeric values from a custom field

Andreas Safar July 23, 2021

For better capacity planning we introduced the custom fields "FE-Estimates" and "BE-Estimates".

Both are numeric fields.

image.png

image.png

So now I want to sum all values from all stories into the same custom field within an Epic.

How can I do that?

I tried the following but it's not workingimage.png

 

3 answers

1 accepted

1 vote
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 11, 2024

Hello, community!

As noted in the other answers for this question, summing custom fields with Jira Cloud may use the Lookup Issues action: https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Lookup-issues

However for Jira Server and Data Center, the initial version of Lookup Issues does not support all fields yet.  Please watch / vote here to see progress on that work: https://jira.atlassian.com/browse/JIRAAUTOSERVER-877

The work-arounds for Server and Data Center versions depend upon what you want to do with the sum value(s):

Using that second method, a custom field is summed like this:

{{webhookResponse.body.issues.fields.customfield_12345.sum}}

If you run into problems, remember to write the response body to the audit log and confirm you have the correct smart values for your fields.

Kind regards,
Bill

Jack Brickey
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 12, 2024

Excellent write up Bill. This is sure to help others.

Like Bill Sheboy likes this
2 votes
Timur Khakimyanov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 6, 2021

I just spent few hours trying to implement Bill Sheboy second proposal, and finally success! Hope this post will help someone to save time:

1.png

No rocket science, but you have to be very careful about parameter names and such.

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.
September 7, 2021

Hi @Timur Khakimyanov -- Welcome to the Atlassian Community, and well done!

The part I find interesting about your web request, custom data is passing the entire {{lookupIsssues}} smart value rather than parsing the keys/id values out into a CSV list, such as: {{#lookupIssues}}{{key}}{{^last}},{{/}}{{/}}

Looks like your version works for you, and so meets the goal!

Kind regards,
Bill

Andreas Safar September 9, 2021

Hi @Timur Khakimyanov thank you for your post. I' ve copied your solution and it works for me. 

0 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 23, 2021

You cannot sum values across all stories. The automation math functions work within an issue. So you can sum two numeric fields within an issue. You might need to look at some add-on for this.

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.
July 23, 2021

Hi @Andreas Safar -- Welcome to the Atlassian Community!

Yes, and...to what Jack noted: Are you using the Server or the Cloud version?

I note you are trying to sum custom field values with Lookup Issues. 

Best regards,
Bill

Andreas Safar July 24, 2021

Thank you for your reply. We are using the cloud version.

In other threads I saw comments where the story points or time estimates are summed up in the appropriate fields of their epic. So I was hoping to do the same just with the custom fields. Something like this:

Story 1 has value '5' in custom field

Story 2 gets a '3' entered into the custom field

Both stories are linked to the same epic

-> custom field within the epic gets updated from '5' to '8'

and so on when the custom field is set/changed/removed

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.
July 26, 2021

Andreas you cannot sum on custom fields with Lookup Issues in an automation rule, yet...

Two possible work-arounds are:

  1. Whenever a field of interest changes in a child issue, update the parent using the Change Log.  The risk here is getting out of synch if the rule does not trigger or when multiple issues change in a short timeframe.
  2. Using a webrequest, the REST API, a search filter, and text functions, get all of the issues for the parent and then convert the webrequest response into a list...using sum to add up the results.  The impact is this rule is several seconds slower, but it will be accurate.
Like Timur Khakimyanov likes this
Andreas Safar July 27, 2021

Hi Bill, thank you again for your support. I've voted for JRACLOUD-75018

I'll try to handle it with the proposed work-arounds.

 

 

Just for your reference in the meantime I've tried the following:

With the following rules the custom field on the parent issue is changing from NULL to 0

image.png

 

see the history:

image.png

 

I'm getting the same effect with

{{lookupIssues.customfield_10066.sum}}

{{Issues.customfield_10066.sum}}

{{lookupIssues.fields.customfield_10066.sum}}

{{Issues.fields.customfield_10066.sum}}

{{lookupIssues.subtasks.fields.customfield_10066.sum}}

 

where the following has no impact on the epic issue

{{Issues.subtasks.fields.customfield_10066.sum}}

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.
July 27, 2021

Yup... {{issues}} (note the plural) is a Server version smart value used in conjunction with that batch/scheduled trigger I noted.  It doesn't work for Cloud version.

The equivalent for Cloud version batch processing is Lookup Issues...and that feature does not support custom fields.

Please see the two work-around ideas I offered to see if one of those will work for you.  Thanks!

Dennis Hansen March 6, 2024
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 6, 2024

Hi @Dennis Hansen 

This issue was resolved long ago for Jira Cloud, but still exists for Jira Server / Data Center automation rules.  I am curious, what is the purpose of your post?

Thanks, and kind regards,
Bill

Tomislav Tobijas
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 11, 2024

Hi @Bill Sheboy ,

I've just stumbled upon this limitation on DC. Regarding possible workarounds you've mentioned, particularly 2nd method - how can you convert the webhook response to a list? I've sent a REST API web request (JQL) and got several issues as a result there. With that (response), how can you convert that to a list and use list.sum function?

On webhook response, I've tried {{webhookResponse.issues.customfield_XYZ.sum}} but that ain't working 👀

Cheers,
Tom

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 11, 2024

Hi @Tomislav Tobijas 

You are quite close to the answer...It helps to post the entire response to the audit log and confirm the response structure as that will show using both the body and fields to get at the data.

{{webResponse.body.issues.fields.customfield_12345.sum}}

That works for me for Jira Cloud, so please confirm it for your Data Center rule.

Kind regards,
Bill

Like # people like this
Tomislav Tobijas
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 11, 2024

You're a lifesaver @Bill Sheboy 😄

I've been struggling with web response as there's only one browser I can use in this specific environment and it doesn't format JSON response automatically (+all online formatters are also restricted by network security policy).

Anyway, I've tested it on this DC environment and it works perfectly! The only difference is that webhook responses are accessible via

{{webhookResponse}} 

while on cloud it is

{{webResponse}}

Cheers,
Tom

Like Bill Sheboy likes this
Jack Brickey
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 11, 2024

@Bill Sheboy , it might be worthwhile pulling out the details of the answer into a separate answer and then @Tomislav Tobijas or I could accept it.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events