Thursday, October 13, 2022

lightning-tree-grid - Account Hierarchy Using lightning-tree-grid in LWC

 In this blog, I am going share a approach through which you can display account hierarchy using lightning tree grid. You can place this lightning component on account record page and it will detect the current account record Id and will display the complete hierarchy.

I am utilising formula field called "Ultimate Account id" to avoid multiple SOQL in apex to get list of all account in the hierarchy. This component can display all account which are up to 10 level deep in hierarchy.

Please refer below URL to get more idea about Ultimate Account Id formula field.

How to get list of all accounts present in account hierarchy in Salesforce

In this LWC component, I am just passing the account Id to apex method and apex method returns all the account list which are present in hierarchy. In order to display account in tree grid, I am creating data in js which will be accepted by tree grid. So in this approach, manipulation on apex side is very simple.

Note: Create Ultimate Account Id formula field on account first in order to implement below code.

Complete Code:

Hope this will help!!!


  1. Hello, This blog is very informative for every one, It's a Great think to help everyone thanks. Visit our website and find Great products in very cheap price

  2. Nice blog post.
    Sobha Galera luxury project provides 4 BHK row house launching in Hoskote, Bangalore

  3. Thank you for this informative post this blog contains some interesting topics keep doing this work also have a look on this School with best rating

  4. Hi there,
    loved all that you shared ,so clear and easy to follow.
    is there any issue your laptop ....We are provide solution
    Laptop Service Center in Chennai

  5. Personal protection tops the list of reasons why firearm owners say they own a firearm . In a Gallup survey conducted in August 2019, firearm owners were most likely to cite personal safety or protection as the reason they own a firearm . Roughly six-in-ten (63%) said this in an open-ended question. Considerably smaller shares gave other reasons, including hunting (40%), nonspecific recreation or sport (11%), that their firearm was an antique or a family heirloom (6%) or that the firearm was related to their line of work (5%) with an ammo .

  6. There are 120 firearms for every 100 Americans, according to the Switzerland-based Small Arms Survey (SAS). No other nation has more civilian firearms than people. While the exact number of civilian-owned firearms is difficult to calculate due to a variety of factors – including unregistered weapons, the illegal trade and global conflict – SAS researchers estimate that Americans own 393 million of the 857 million civilian firearms available , which is around 46% of the world’s civilian firearm cache . About 44% of US adults live in a household with a firearm, and about one-third own one personally, according to an October 2020 Gallup survey.