Skip to main content

Hello experts,

I have two custom fields TopLevelAccount__c (Look up) and HierarchyLevel__c (decimal field) on Account. 

If the field “Account.ParentId” is not empty

1. check if the new related record has also a value in "ParentId"

     a. If yes, evaluate the next Account behind the lookup "ParentId" till you reach the top level Account and memorize the Account ID

     b. If no, memorize the related Account ID

 

2. write in "Account.TopLevelAccount__c" the memorized Account ID

3. calculate the level in this hierarchy stages for the inserted/updated Account and write the value in

"Account.HierarchyLevel__c"

 

Notice that, in case the value "Account.ParentId" is updated to NULL or is reapended, the values in "Account.TopLevelAccount__c" and "Account.HierarchieLevel__c" must be recalculated for this and the related Accounts (Account.ChildAccounts).

 

Your help would be greatly appreciated!!

2 respuestas
  1. 18 abr 2024, 20:36

    Thanks for your reply.

    1. In your Salesforce Instance, what is the maximum number of Hierarchy Levels for any set of Accounts? : Up to 5 or 6.

    2. Did you already populate TopLevelAccount and HierarchyLevel within your current Accounts? I tried but it didn't work.

    3. What is the nature of these Accounts? Specifically, why are there (potentially) so many levels in a hierarchy? This is how accounts are setup in my org. These are more commercial accounts.

0/9000