Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to sum custom fields in parent issue ?

 

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

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

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

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!

Bill 

I send what you ask for

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

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).

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

@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

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!

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 !!

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}}

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!!!

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

Thanks!

Like Jonathan Santos likes this

@Bill Sheboy  the rule working as i expect.

 

2022-01-12_15h40_03.png

Thanks !!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Software

👋 Looking for 15-20 volunteers to test Atlassian training content

Hi everyone! Are you interested in beta testing Atlassian University’s newest (unreleased!) training course? We’re looking for 15-20 volunteers to test our newest training course, Basic reporting...

611 views 21 25
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you