function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Roll-up count of Account related objects across hierarchy

I've tried several approaches to this, and I'm not really happy with any of them. I'm hoping someone here can point me to a best practice example.


I have a custom object related list on accounts. On every account, I want to see the total record count of these objects that exist below it in the hierarchy. For example:


Child Account 1 of Parent Account 1 has 2 related records, Child Account 2 of Parent Account 1 has 3 related records. The record total field on Parent Account 1 would show 5.


If it helps, I've programmatically constrained my account hierarchy to 3 levels. 


 In order to answer your question correctly I need to understand how are you making this calculation.

Are you using:-

1. Summary fields

2. Triggers- In triggers you can easily do it by check if the parent id of the current record has a parent or not

to calculate this.

Ideally as you have 3- level of hierarchy you should use triggers for calculating this.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.