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
Melissa BunchMelissa Bunch 

Display Account Hierarchy in Lightning Component on the Account Lightning Record Page


I would like to display the actual Account Hierarchy within a Lightning Component on the Lightning Record Page for my Accounts.

I was able to find code to add a Lightning Component that links to the hierarchy, but I want to actually display the hierarchy instead.

Does anyone know how to do this? Below is a screenshot of the code I found and how it looks. Maybe I can edit the existing code to display the hierarchy?

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">
    <div class="slds-section slds-is-open">
        <h3 class="slds-section__title">
            <button aria-controls="expando-unique-id" aria-expanded="true" class="slds-button slds-section__title-action">
                <lightning:icon iconName="utility:switch" alternativeText="" size="x-small" />
                <span class="slds-truncate" title="Section Title"> &nbsp;Account Hierarchy Link</span>
        <div aria-hidden="false" class="slds-section__content" id="expando-unique-id">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="{!c.navigateToAccountHierarchy}">View Account Hierarchy</a>


    navigateToAccountHierarchy: function(cmp, event, helper) {
        var acctId = cmp.get('v.recordId');
        var evt = $A.get("e.force:navigateToComponent");
            componentDef: "sfa:hierarchyFullView",
            componentAttributes: {
                recordId: acctId,
                sObjectName: "Account"

User-added image
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Melissa,

Please find the code from the below link. I implemented the same and it is showing us the account hirerachy when we onclick the link as expected.

User-added image

If this solution helps, Please mark it as best answer.