Saving existing records

To save existing records, use EDIT mode in the force:recordData component. The controller markup is as follows:

<force:recordData aura:id="recordComponent"      recordId="{!v.recordId}"      layoutType="FULL"      targetRecord="{!v.record}"      targetFields="{!v.simpleRecord}"      targetError="{!v.recordError}"      recordUpdated="{!c.handleRecordUpdated}"      mode = "EDIT"      />

The controller function is as follows:

 component.find("recordComponent").saveRecord($A.getCallback(function(saveResult) {            // NOTE: If you want a specific behavior(an action or UI behavior) when this action is successful             // then handle that in a callback (generic logic when record is changed should be handled in recordUpdated event handler) if (saveResult.state === "SUCCESS" ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.