How to sum custom fields in parent issue ?

Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2022

 

Hi everyone, i am trying create an automation rule but unsuccessfully.
I need tu sum a value in a custom field (numeric) in a sub-tasks.
Example:
Sub-task 1 Custom field (Imputación Real) = 5
Sub-task 2 Custom field (Imputación Real) = 3
Parent Issue (Story) Custom field (Imputación Real) = 8

when update the field in a subtask, automatically update custom field in parent issue

{{#=}}{{{issue.parent.customfield_10058)}+ {{triggerIssue.customfield_10058}}}{{/}}

 

How do I know the name of the custom field?

2022-01-03_21h20_43.png

where is failed?

 

Thanks !

2 answers

1 accepted

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.
January 4, 2022

Hi @Jonathan Santos 

First thing, you appear to have too many curly brackets around the smart values.  There should be 2 around each term, such as:

{{#=}} {{issue.field_A)} + {{issue.field_B}} {{/}}

More importantly, are you certain this is what you want to do in this rule?  This will add the value to the parent every time it changes, growing larger every time.

Or, do you want the parent to contain the sum of the values in the subtasks?  To do that, I recommend a different approach to re-compute the sum when any subtask changes:

  • trigger: issue field changes for your custom field
  • condition: issue type is subtask
  • action: lookup issues with JQL to get all of the subtasks of the parent
    • parent = {{triggerIssue.parent}}
  • branch: on the parent issue
    • action: edit the field with the sum of your field
      • {{lookupIssues.customfield_10058.sum|0}}

Kind regards,
Bill

Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2022

Hi @Bill Sheboy 

Thanks

 

I did what you told me but not successfully.
The sum of automation edit the field a 0

 

2022-01-04_16h04_13.png

Story (Parent Issue) Custom field = 0

2022-01-04_16h13_52.png

Subtask (custom field = 1)

2022-01-04_16h14_00.png

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.
January 4, 2022

I wonder if there is an problem with the field type being parsed correctly.  Is it numeric or text field?

Perhaps try this instead:

  • {{lookupIssues.customfield_10058.value.sum|0}}

Also, would you please post an image of your audit log showing the details from the rule running?  That may reveal what is happening.  Thanks!

Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2022

Bill 

I send what you ask for

2022-01-04_17h04_54.png2022-01-04_17h05_17.png

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.
January 4, 2022

That is interesting as Lookup Issues should now support custom fields.

After the lookup issues action, please try writing these two values to the audit log, and then post that image of the audit log after trying to run the rule again:

  • {{lookupIssues.first.key}} : {{lookupIssues.first.customfield_10058}}
  • {{lookupIssues.last.key}} : {{lookupIssues.last.customfield_10058}}

As your story only has two subtasks, that should write the key and custom field value for subtasks CA-14 and CA-15 (not necessarily in that order).

Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2022

Hi @Bill Sheboy  

do what you told me

2022-01-05_12h28_58.png

but it shows me the following error

2022-01-05_12h26_59.png

the field is  customfield_10059

Try another automation rule, which so far works fine,in which I use the story points field to add the values and thus add in the custom field

2022-01-05_12h30_49.png

I will continue to try your help
Thank you

Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2022

@Bill Sheboy

In the audit log i see is adding a. after the existing value in the custom field:

2022-01-05_13h52_01.png2022-01-05_13h52_44.png

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.
January 5, 2022

I see some extra spaces in your smart value after the first and last terms.  Try removing the extra spaces from the smart value and see what happens.  Thanks!

Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 11, 2022

Hi Bill I remove the extra spaces 

2022-01-11_15h41_28.png

I run the rule , but not sum 

2022-01-11_15h44_18.png

 

what is mi error?

Thanks !!

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.
January 11, 2022

In your image, it looks like there is only one curly bracket before lookupIssues.  Please make sure they are in pairs around the smart value and try it again.

{{lookupIssues.customfield_10059.sum|0}}
0 votes
Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 12, 2022

Hi @Bill Sheboy 

now if you are adding the two values.
Thanks for your help and patience.
You are a great colleague

2022-01-12_09h39_10.png

THANKS!!!

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.
January 12, 2022

@Jonathan Santos is the rule now working as you expect?  Or is there another issue?

Thanks!

Like Jonathan Santos likes this
Jonathan Santos
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 12, 2022

@Bill Sheboy  the rule working as i expect.

 

2022-01-12_15h40_03.png

Thanks !!

Like Bill Sheboy likes this
Rich Nuzzi September 23, 2022

@Bill Sheboy Been following this for an automation that I have running. The challenge that I am running into is that I am adding several fields in subtasks and summing them in the parent. I have all number fields, I have 0 as the default value in all. If I input one number into just one of the fields, the automation says successful, but it still reads 0. If i input numbers into 2 fields, it works. Why would that be?

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 23, 2022

Hi @Rich Nuzzi 

First thing: only people following this thread may see your question, so for older posts consider creating a new question and add a link to the older ones for context.

Would you please post images of your complete rule, including details of the field addition, and of the audit log showing details of an execution?  That may provide some context for what is happening.

Thanks, and kind regards,
Bill

Like Shachar Tzuk-Bazak likes this

Suggest an answer

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

Atlassian Community Events