I am try to call lightning component from VF Page and trying to call force:createRecord from lightning component. but getting below error message:

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

Below is code snipped

VF Page

    <apex:includeLightning />

    <div id="lightning" />

        $Lightning.use("c:workLineItemApp", function() {
          { label : "" },
          function(cmp) {

Lightning App

<aura:application access="GLOBAL" extends="ltng:outApp">
   <aura:dependency resource="c:workLineItem"/>


<aura:component implements="force:appHostable" access="global" >
   <aura:handler name="init" value="{!this}" action="{!c.doInit}" />    


  doInit : function(component, event, helper) {

       console.log("WorkLineItemController.doInit: Entered");

       var createNewRecord = $A.get("e.force:createRecord");

           'entityApiName': 'WorkOrderLineItem'

       console.log("WorkLineItemController.doInit: Exit");

  • Is this is classic or lightning? Nov 2, 2018 at 20:35
  • I am calling VF page from lightning related list button (List Button)
    – Lalit
    Nov 2, 2018 at 20:37

2 Answers 2


The force:createRecord event is

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

Visualforce Lightning Out pages are not equivalent to the one.app container and do not support this and many other events.

If your core objective, as you mention in comments, is to prepopulate fields upon record creation, I would encourage you to try to execute this requirement using the purely declarative functionality available through Lightning Quick Actions of the Create Record type. You can add predefined field values, including static values and formula expressions, that will be populated whether or not you include the field on the Quick Action's layout. You can find examples on Trailhead.

If this does not provide enough flexibility, you can write a custom Lightning component and surface it as a Quick Action within Lightning Experience. The Visualforce page button is causing you to do a lot of unnecessary work and limiting your solution options.

  • Thanks David. Do you have any example of one.app container? also would i be able to call from List Button? because don't have option to call any other way.
    – Lalit
    Nov 2, 2018 at 20:57
  • The one.app container is, among other things, the Lightning Experience itself. You can use this event in a Lightning component that is presented directly in Lightning. You cannot use the event in a Lightning component in a Visualforce page.
    – David Reed
    Nov 2, 2018 at 21:00
  • probably i am not able to properly because i am new to this one.app. Let me clarify my requirement. I have to create new record with pre-populated values once i click on button in lightning. I know, it's easy to do in classic with URL hack. not sure, if i am going in right direction or not (calling VF page then lightning component from VF page). Also i don't anything about one.app because i am new to saleforces. Do you have any other way to pre-populate field values when we open create new record window in lightning?
    – Lalit
    Nov 2, 2018 at 21:14
  • I've added some information in my answer.
    – David Reed
    Nov 2, 2018 at 21:19
  • Thanks David. Problem with Quick Action is that you can not place it on related list
    – Lalit
    Nov 2, 2018 at 21:40

An alternative would be to instead use a lightning:recordEditForm to create the record. This is the component I use when embedding forms, or prepopulated forms in visualforce from lightning components.

You will however need to add more code to your markup and handle what happens once the record is created.

You must log in to answer this question.

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