I have a lightning Component to display the Account and its Contact relationship in tree view using Accordion SLDS. On this page, I want to put "New Contact" button to create a contact record.

Is it possible to get the standard lightning experience popup to create a record from New button on lightning component?

I tried the below one, but no luck,

<ui:button label="New" press="{!c.createRecord}"/>


    createRecord : function (component, event, helper) {
        var createRecordEvent = $A.get("e.force:createRecord");
            "entityApiName": "Contact"

getting error:

$createRecord [Cannot read property 'setParams' of undefined]

Is there any way out there to get the standard lightning experience record creation page layout by clicking the New button in lightning component?.

Thanks in advance!

  • why the visualforce and Apex tags?
    – glls
    Commented Jan 5, 2018 at 19:24
  • Am very new to lightning experience. Since visualforce is a successor of lightning components, tagged it.
    – Prince
    Commented Jan 5, 2018 at 19:26
  • please remove them, as well as the apex tag, as they are unrelated for your use case (or so it would seem). One last question, where are you using this component, in communities or lightning experience?
    – glls
    Commented Jan 5, 2018 at 19:28
  • Lightning experience
    – Prince
    Commented Jan 5, 2018 at 19:29
  • I honestly cant spot anything wrong with your component, did you create an app throught the app builder , drag and drop it, and this is the e rror you get every time you click your button?
    – glls
    Commented Jan 5, 2018 at 19:53

2 Answers 2


I resolved it. Am posting here to save other's time,

I was getting that error if am viewing the page from application preview. Then I placed a lightning component tab and try to click on the button, it is opening the record creation popup.

  • 1
    make sure you accept your answer =)
    – glls
    Commented Jan 12, 2018 at 0:35
 var createLeadEvent = $A.get("e.force:createRecord");
            "entityApiName": "Lead",
            "defaultFieldValues": {
                    'Title' : 'TestRecord',
                    'FirstName' : 'TestFirstName',
                    'LastName' : 'TestSecondName',

Here, createRecord - is an inbuilt event to force create a new record, entityApiName - it defines an Object where you go to create a record, defaultFieldValues - defines prepopulate data.

  • This approach works with hard-coded default field values. Is there some way of passing variables for the fields?
    – abhi
    Commented Jun 11, 2019 at 18:49

You must log in to answer this question.

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