[SalesForce] How to redirect to the standard Lightning Account Hierarchy page?

How can I add a button to the custom lightning component, which will be hidden is Account is not a part of hierarchy and, if visible, will redirect to the standard Lightning Account Hierarchy page for this Account (the one which gets open if you click on the hierarchy image next to the Account's name or if you select a 'View Account Hierarchy' action)?

The classic page has a specific URL (/acc/account_hierarchy.jsp?id=), but LEX page URL is a set of random symbols…

Best Answer

I also wanted to create a Lightning component that would indicate if the account was a part of a hierarchy (had a parent or children), and if so, link to the account hierarchy page.

Here's how I was able to link to the Lightning experience version of the account hierarchy page in a Lightning component:

AccountHierarchy.cmp (Component):

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">
    <a onclick="{!c.navigateToAccountHierarchy}">Go to Account Hierarchy</a>

AccountHierarchyController.js (Controller):

    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"
Related Topic