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...

closed as off-topic by glls, battery.cord, Pranay Jaiswal, Gortonington, Raul Dec 10 at 11:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – glls, battery.cord, Pranay Jaiswal, Gortonington, Raul
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Why do you want to have it shown from your component if you can already add the action on the account record page? Is there a specific use case here? – Jayant Das Dec 3 at 21:37
  • Yes, we need the hierarchy button to be shown only if there is an hierarchy for this Account, and standard action/button can't be hidden, as far as I know... – hanna Dec 6 at 10:25
up vote 0 down vote accepted

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>
</aura:component>

AccountHierarchyController.js (Controller):

({
    navigateToAccountHierarchy: function(cmp, event, helper) {
        var acctId = cmp.get('v.recordId');
        var evt = $A.get("e.force:navigateToComponent");
        evt.setParams({
            componentDef: "sfa:hierarchyFullView",
            componentAttributes: {
                recordId: acctId,
                sObjectName: "Account"
            }
        });
        evt.fire();
    }
})
  • Thank you very much! – hanna Dec 11 at 10:13
  • Where did you figure this out? – Charles T Dec 11 at 12:29
  • @CharlesT I wasn't able to find anything online about how to get to the account hierarchy page. What I ended up doing was using Chrome's developer tools, going to the Network tab, and then watching what calls Salesforce was making to get to that page. I took a look at the response to the first call, and buried in the response was "componentName":"force:navigateToComponent", so I was able to figure out that was a component I could use, and then I tried to see if I could navigate to the "sfa:hierarchyFullView" component, and, much to my surprise, it worked. – Scott Blaine Dec 12 at 15:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.