Using the Salesforce Account Hierarchy

The Salesforce account hierarchy allow accounts to be related in a hierarchy by using a ‘parent account’ field to link them together. Once linked, the complete hierarchy structure can be viewed and links are provided to navigate directly to the accounts.

The first step is to create or identify the ultimate ‘Parent’ account. This is the account at the top of the hierarchy. In our example, the top level account is Acme.

Parent Account

Then one or more accounts are created or linked to each level of the hierarchy, using the Parent Account field. In our example, we are linking Brown Company to the top level account Acme.

Setting Parent Account

Once the hierarchy has been built, the ‘View Hierarchy’ link can be used to view all of the accounts that have been related to each other in a separate page. In our example we have 11 levels, probably more than you would need. Accounts are indented to show the different levels.

Account Hierarchy

Now that a multi-level hierarchy has been built, a common requirement is to identify the ‘ultimate parent’ for each account in the hierarchy. For example, if we are looking at the Ice Company record, we want to know what is the company at the top of the hierarchy that the Ice Company belongs to. We can do this by adding a text formula field to the account object.

Ultimate Parent Formula Field

Copy the formula from the textbox below into the formula field just created. It will check up to 10 levels for the ultimate parent.

IF( LEN(Parent.Name)<1 ,HYPERLINK("/"&Id, Name,"_parent"), IF( LEN( Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Id,Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Id,Parent.Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Parent.Id,Parent.Parent.Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Parent.Parent.Id,Parent.Parent.Parent.Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Parent.Parent.Parent.Id,Parent.Parent.Parent.Parent.Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Parent.Parent.Parent.Parent.Id,Parent.Parent.Parent.Parent.Parent.Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id,Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id,Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name,"_parent"), IF( LEN( Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name )<1 ,HYPERLINK("/"&Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id,Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name,"_parent"), "Ultimate Parent Beyond 10 Levels"))))))))))




Here is the account page layout with the ‘Ultimate Parent’ field added. As Acme is the top level, it is listed as the ultimate parent.

Ultimate Parent

Here is an example of how the ultimate parent formula works at one of the levels of the hierarchy. The Jelly company has a parent of the Ice Company and the ultimate parent is displayed correctly as the Acme account.

Jelly-Ice

Our formula stops at 10 levels, so for the Kandy company, a message is displayed that the ultimate parent is beyond 10 levels.

Ultimate Parent Beyone 10 Levels

Some things to keep in mind when using the Account hierarchy:

  • The parent account hierarchy is not supported for person accounts
  • There is a limitation of displaying up to 500 accounts
  • If the user displaying the hierarchy doesn’t have access to the account data, the additional columns displayed to the right of the account name won’t be displayed
  • A Custom Report Type will be needed to report on hierarchies more than one level deep
  • The “View Hierarchy” page is not editable. This means you are cannot change the columns that are displayed e.g. Type, Industry, Billing City, Billing State and Owner. If you do want a custom view you will need to create a custom Visualforce page or look for an app in the AppExchange.
  • One account can’t have multiple direct parents