<aura:component >
    <aura:attribute name="myfields" type="String[]" default="['FirstName', 'LastName', 'Email']"/>
    <aura:attribute name="con" type="Object"/>
    <aura:attribute name="Newcon" type="Object"/>
   <!-- Here mydata is to use in controller -->
    <aura:handler name="init" value="{!this}" action="{!c.IniMe}"/>
    <force:recordData aura:id="mydata" fields="{!v.myfields}" targetFields="{!v.con}" targetRecord="{!v.Newcon}"/>
    <lightning:card title="New Contact Creation">
        <lightning:input label="Contact First Name" value="{!v.con.FirstName}"/>
        <lightning:input label="Contact Last Name" value="{!v.con.LasttName}"/>
        <lightning:input label="Contact Email" value="{!v.con.Email}"/>
        <lightning:button label="save" onclick="{!c.saveme}"/>


    IniMe : function(component, event, helper) {
    saveme : function(component, event, helper){


<aura:application extends="force:slds">
  • You are missing the whole exception handling in your LDS, also there is a typo in result.redordId
    – Raul
    Commented Mar 16, 2021 at 13:54
  • Does this answer your question? ID of record created with force:recordData, the Lightning Data Service
    – Raul
    Commented Mar 16, 2021 at 13:55
  • Ah I see, here is an example in ldsSaveRecordController.js. Basically in the saveRecord function, you need to check the state and exact error so as to notify the user about it. That would give you clue on why the insert fails.
    – Raul
    Commented Mar 16, 2021 at 14:06
  • @Mahi Five of your last six questions have been problems caused by misspellings in your code. We're happy to help, but please take some time to carefully proofread your code. These errors are easily avoidable, and I'm sure it's frustrating to you too!
    – David Reed
    Commented Mar 17, 2021 at 1:11
  • @DavidReed I am Checking the code quite a few times. Unable to find the error. Can't explain how disappointing it is if code fails bcz of small typo and unable to find. I am glad that you guys are kind enough to help everytime which makes me keep going. Is there any way to findout the location of error? Tq..David
    – user90016
    Commented Mar 17, 2021 at 5:50

1 Answer 1


You have a typo in a critical field for Contact creation - the LastName field.

Change this:

<lightning:input label="Contact Last Name" value="{!v.con.LasttName}"/>

To this:

<lightning:input label="Contact Last Name" value="{!v.con.LastName}"/>

And I'm pretty sure it'll work. Even with the typo mentioned in the comments, it'll still work, but you'll need to fix that too, to get a visible result in your component.

Also, to capture any errors on contact creation, you should check for errors:

    if (result.state == 'ERROR'){
        alert('ERROR!! ' + result.error[0].message);
    else {
        alert('Created!! ' + result.recordId);

You must log in to answer this question.