3

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.

  • 1
    I used the same approach. Empty modal comes up, closes itself (with a little 'just a moment message') and redirects user. Its ugly but works. – Christian Szandor Knapp Aug 17 '17 at 9:49
  • 1
    I did the same workaround. It really looks ugly and I would be happy to replace it. – RichardT Aug 19 '17 at 11:59
  • 2
    Same for me, too. Using this desperate workaround. I think we need Salesforce to add this feature... – Uwe Heim Aug 19 '17 at 12:03
  • 1
    I use the same workaround, I was able to keep the modal appearing to a minimum time by using $A.get("e.force:closeQuickAction").fire(); – Itai Shmida Aug 20 '17 at 5:28
  • 1
    There is a new answer on this question that may be helpful, though I have not tried it. salesforce.stackexchange.com/questions/170291/… – JRiffe Aug 21 '17 at 17:20
2
+25

This is not the Best solution but you can create a visualforce page and URL button to do this.

The visualforce page will get id from URL and then pass that id to the component.

Visualforce page will be

<apex:page showHeader="false" standardController="objectName">

    <apex:includeLightning rendered="true"/>
    <div id="lightning" />

    <script>
        var recordId = "{!$CurrentPage.parameters.id}";
        $Lightning.use(
            "c:demoapp", 
            function() {
                $Lightning.createComponent(
                    "c:otherComponent",
                    { marketId : recordId  },
                    "lightning",
                    function(cmp) {}
                );
            }
        );
    </script>
</apex:page>

Then create a Url button with Url

<yourInstance>/apex/<VisualForcepageName>?id={!objectName.id}

Then add this URL button in your page layout in Salesforce Lightning button section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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