Skip to main content
Notice removed Canonical answer required by CommunityBot
Bounty Ended with Manjot Singh's answer chosen by CommunityBot
Tweeted twitter.com/StackSalesforce/status/898882597908041728
Notice added Canonical answer required by Robert Sösemann
Bounty Started worth 50 reputation by Robert Sösemann
edited title
Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508

Navigate to Lightning component from native record page (without modal)

Source Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508

Navigate to Lightning component from native record page

I understand that I can add a Quickaction to a custom object to load a Lightning component from a native record page in Lightning.

But..this component is displayed in a Modal on top of the original page. I don't want that. I want to redirect to a new "page".

The best thing I could come up with was a empty "button" component which redirects on init.

Markup

<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">
    <!-- Note: Just redirects to another page -->
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
</aura:component>

Controller

({
    init : function(cmp, evt, helper) {
        var evt = $A.get("e.force:navigateToComponent");
        evt.setParams({
            componentDef: "c:otherComponent",
            componentAttributes: {
                marketId: cmp.get("v.recordId"),
                isredirect: true
            }
        });
        evt.fire();
    }
})

This works but is ugly as I see that the page is loaded for a second. I also want to get rid of extra button components.