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);
}
})
);
}
})
Is this is known issue/ behaviour or i'm missing anything here.