3

I'm trying to use force:createRecord and it works okay in Lightning Experience, and S1 but but I get the following error message when I am using a stand alone app. If I preview the "sampleCreateRecordApp.app" I get the below error message:

"This page has an error. You might just need to refresh it. Action failed: c:sampleCreateRecord$controller$createRecord [Cannot read property 'setParams' of undefined] Failing descriptor: {c:sampleCreateRecord$controller$createRecord}"

Below is the simple compoment I'm trying to get to work in a stand alone app (or lightning out). The documentation link here alludes that they can be used outside of LEX or S1

If I try to extend the application with extends="ltng:outApp" the application does not render at all. Any advice would be great. Thanks!

sampleLightningOutPage.page

<apex:page >


    <script src="/lightning/lightning.out.js" />
    <div id="sampleComponentDiv" />    

    <script> 
        $Lightning.use("c:sampleCreateRecordApp",function() {
            $Lightning.createComponent(
                "c:sampleCreateRecord",
                {},
                "sampleComponentDiv"
            );

        });
    </script>
</apex:page>

sampleCreateRecordApp.app

<aura:application >
    <c:sampleCreateRecord/>

</aura:application>

sampleCreateRecord.cmp

 <aura:component implements="flexipage:availableForAllPageTypes">
    <lightning:button variant="brand" label="Submit" onclick="{! c.createRecord }" />


</aura:component>

sampleCreateRecord.js

({
    createRecord : function (component, event, helper) {
        var createRecordEvent = $A.get("e.force:createRecord");
        createRecordEvent.setParams({
            "entityApiName": "Contact"
        });
        createRecordEvent.fire();
    }
})
2
  • can you share your visualforce page code also? Feb 23, 2017 at 5:52
  • I updated my post to include the visualforce page as well. Thanks for your help in advance!
    – jojopogi
    Feb 23, 2017 at 18:31

2 Answers 2

3

The force:createRecord feature is unsupported for ligtning out - as stated in the documentation:

This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce app, and Lightning communities.

That means - not available on lightning out and therefore inside a visualforce page.

3
  • The documentation link you provided is not working. Can you please share the link again Jun 29, 2018 at 2:04
  • @MonalisaDas updated! Feb 5, 2019 at 13:10
  • wre you able to do it with any work arounds ?
    – ScoRpion
    Apr 22, 2019 at 13:22
0

@Monalisa Das

You can find the updated documentation here - force:createRecord Documentation

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .