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
KirstyFranceKirstyFrance 

Summarising data on a parent account

Hello,

 

Does anyone know if it is possible to summarise data on a parent account from the accounts in its hierarchy. I know how to do this on an account from any child objects on that account, but can't find away to summarise information a the parent account level in relation to the accounts in its hierarchy.

 

An example would be that each account has a monthly revenue field, the monthly revenue field on the parent account should be the sum of the monthly revenue fields on all the account below it in the hierarchy?

 

Any help appreciated.

 

Kirsty

Best Answer chosen by Admin (Salesforce Developers) 
Ritesh AswaneyRitesh Aswaney

The Parent field on Account is a reference to the Parent Account.


Therefore you can use

 

Select Id, Name  from Account where ParentId = '....'

to return all the children account of a Parent

All Answers

Ritesh AswaneyRitesh Aswaney

Hey,

Rollup Summary Fields can do that for you in a Master-Detail relationship, but since Account hierarchies are self reference relationships, don't reckon its possible.

 

This idea thread also seems to suggest this

http://success.salesforce.com/ideaView?id=08730000000BrqGAAS

 

Which means, if you want to do this, it will have to be an Apex Trigger, rather than config.

KirstyFranceKirstyFrance

Thanks for your reply Ritesh. I've promoted the idea of making it out of the box.

 

I've used rollup summary fields for master-detail relationships before and I know how to reference a parent account on a child account via a trigger, but I don't know how to reference the child account on the parent account in APEX.

 

Do you have any of the syntax for that?

 

Regards

 

Kirsty

Ritesh AswaneyRitesh Aswaney

The Parent field on Account is a reference to the Parent Account.


Therefore you can use

 

Select Id, Name  from Account where ParentId = '....'

to return all the children account of a Parent

This was selected as the best answer