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" || saveResult.state === "DRAFT") {
// handle component related logic in event handler
} else if (saveResult.state === "INCOMPLETE") {
console.log("User is offline, device doesn't support drafts.");
} else if (saveResult.state === "ERROR") {
console.log('Problem saving record, error: ' + JSON.stringify(saveResult.error));
} else {
console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
}
}));

It is important to use aura:id to find the target component. The syntax to find the component with the aura:id value recordComponent is as follows:

component.find("recordComponent")

The force:recordData component consists of a function, saveRecord, that saves the data and provides a callback function to handle SUCCESS and failures. The following lines of code save the record, using saveRecord

component.find("recordComponent").saveRecord($A.getCallback(function(saveResult) {

}
For saving existing records, you will need to make sure that the recordId is provided in the force:recordData component.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.172.38