Sum up sub-task custom fields to Epic custom field
Asked by Laviniu Chis:

Hi there,

I'm trying to create a rule to sum up at Epic level "Venituri totale proiecte depuse ?" (customfield_10099) all custom fields (customfield_10090) from all child issues (stories, tasks and especially stories sub-tasks) every time "Valoare factura ?" (customfield_10092) changes.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/336701i466E65C693F84076/image-size/large?v=v2&px=999 "image.png")

This is what I managed to build so far but it doesn't work.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/336702i4D25FD65FF86608E/image-size/large?v=v2&px=999 "image.png")

Any suggestions?


Answers:
author: Trudy Claspill
body: Hello [@Laviniu Chis](/t5/user/viewprofilepage/user-id/5531904)

Does the field "Venituri totale projecte depuse" display in the UI for issue FUE-26? Can you edit that field directly in the UI?

What type of project is the FUE project? Get that information from the Type column on the View All Projects page under the Projects menu.

comments: author: Laviniu Chis
body: Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011)

Thank you for your answer. Yes, the field is displayed in the Epic FUE-47 UI and it is editable. Though, it is not present in the story FUE-26 and its sub-task FUE-39 where the field "Valoare factura ?" is present.

FUE-47 is a business project.


author: Trudy Claspill
body: The way your rule is written, the action to Edit an issue and update the field "Venituri totale projecte depuse" is being applied to the parent of the subtask.

![Screenshot 2024-07-19 at 9.17.17?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/336750iC10EECAED5E6B204/image-size/large?v=v2&px=999 "Screenshot 2024-07-19 at 9.17.17?AM.png")

According to the Audit Log the subtask issue is FUE-62. Its parent issue is FUE-26.

You said the field is not present in the UI in that issue. Therefore the rule can't update the field and instead shows you the error in the audit log.

If you want that field updated in the parent issue, then you have to add that field to the parent issue type's screen.


author: Laviniu Chis
body: I would like the information to be updated in the Epic, not in the sub-task's closest parent. How should I update the rule so that all sub-tasks field "Valoare factura" are sumed up in the "Venituri totale proiecte depuse" field of their parent Epic.


author: Trudy Claspill
body: A rule like this should work using the same trigger you have.

1. Confirm that the issue that triggered the rule is a subtask

2. This is a debugging step to print a message in the log file. At this point the smart value {{issue.parent.parent}} should be the key of the Epic that is the parent of the issue that is the parent of the subtask.

3. Here you branch/change the rule focus to that Epic.

4. Get a list of all the issue that are children or grandchildren (subtasks) under that Epic. Use the "and issueType in subTaskIssueTypes()" criteria to limit the results to only the subtasks.

5. Check that you got at least one issue back in that list.

6. Edit the Epic to update the field in the epic with the sum of the field values in the listed issues. Use the smart value {{lookupIssues.\<your Field in the Subtasks\>.sum}}

![Screenshot 2024-07-19 at 10.32.46?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/336756i783F18CA2AF10C25/image-size/large?v=v2&px=999 "Screenshot 2024-07-19 at 10.32.46?AM.png")


author: Laviniu Chis
body: Thank you [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) for the detailed explanation.

This updated rule worked partially, meaning that now is sums up some values at Epic level,

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/336832iEA15E6FFFA0A2C74/image-size/large?v=v2&px=999 "image.png")

but still it is not the corect value and it does not update when the sub-task issues is updated.

My updated rule looks like this now

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/336834i1053F8C3B6E77FC1/image-size/large?v=v2&px=999 "image.png")

the audit log now shows the following errors (issue FUE-39 being a sub-task)

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/336833iAE9960A66A46C2BF/image-size/large?v=v2&px=999 "image.png")

what am I missing?


author: Trudy Claspill
body: The error message is indicating that the first condition is not being met - the issue type of the triggering issue is not "Sub-task".

Are these issues in a Team Managed project or a Company Managed project?

Is the scope of this rule Global, multiple projects, or a single project?

Also, you don't need the rule Trigger that has multiple events. Try going back to the original trigger that was just "When value changes for" and the specified field.


author: Laviniu Chis
body: Thank you again for your patience [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011)

These issues are in Company Managed project. The scope of this rule is for a single project. I reverted back to initial condition.

now the rule looks like this, but still the values don't sum up.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/337093iAFBE80A4C3CB3586/image-size/large?v=v2&px=999 "image.png")

and the audit log shows

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/337094i1291F7BDCB279081/image-size/large?v=v2&px=999 "image.png")


author: Trudy Claspill
body: That error message is telling you the Smart Value Condition in the branch is not being met.

Smart values can be space and case sensitive. In this case, you are not using the correct capitalization of the smart value. It needs to be lookupIssues with a capital "i".

![Screenshot 2024-07-22 at 10.01.40?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/337096iFFE2004593059052/image-size/large?v=v2&px=999 "Screenshot 2024-07-22 at 10.01.40?AM.png")


author: Laviniu Chis
body: That was it, the capital I. Thank you.


Tags: free

jira

jira-cloud