[SalesForce] Lightning record edit form issues with Person Account

I was rendering the person contact details using lightning record edit form. Updating the person contact details using force:recordData lightning data service.

If i'm updating the person contact details using the saveRecord of data service, in success call back im getting the person account id instead of person contact Id.

Markup:

<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="recordError" type="String" access="public"/>
<aura:attribute name="contactInstance" type="Contact" access="public" />
<aura:attribute name="record" type="Contact" access="public"/>

<lightning:recordEditForm aura:id="submit-sobject" 
                          objectApiName="Contact" 
                          recordId="0034100002BTXzA" >
    <lightning:messages />                 
    <lightning:inputField fieldName="Name" onchange="{!c.bindChangedValues}" />
</lightning:recordEditForm>

<force:recordData aura:id="recordHandler"
                  recordId="0034100002BTXzA"
                  fields="Name"
                  targetRecord="{!v.record}"
                  targetFields="{!v.contactInstance}"
                  targetError="{!v.recordError}"
                  mode="EDIT" /> 

<lightning:button variant="brand" label="Save" title="Save" onclick="{!c.save}"/>

Controller:

({
bindChangedValues : function(component, event, helper) {
    var targetCmp = event.getSource();        
    var contactInstance = component.get("v.contactInstance") || {};
    contactInstance[targetCmp.get("v.fieldName")] = targetCmp.get("v.value");        
    component.set("v.contactInstance", contactInstance);

},
save : function(component, event, helper) {
    console.log('contact Instance-->', JSON.stringify(component.get("v.contactInstance")));
    component.find("recordHandler").saveRecord(
        $A.getCallback(function(saveResult) {                    
            if(saveResult.state === "SUCCESS") {
                console.log('saveResulId', saveResult.recordId);
            }
        })
    );
}

})

enter image description here

Is this is known issue/ behaviour or i'm missing anything here.

Best Answer

Person accounts are special cases. Once person account is enabled in your org, creating a person account internally creates two records (One to represent contact and one to represent associated account)

In general - Account can have multiple contacts, but for person accounts its always 1-to-1.

The behavior is described very nicely in below post:

(Person Accounts & PersonContactId - how are these related?: https://success.salesforce.com/answers?id=90630000000hsNXAAY).

Person Account Documentation

Related Topic