Record Save Success

force:recordSaveSuccess

Indicates that the record has been successfully saved.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App

This event is handled by the force:recordEdit component. This example shows a force:recordEdit component, which takes in user input to update a record specified by the recordId attribute. The button fires the force:recordSave event.

1<aura:attribute name="recordId" type="String" default="003R00000000000000"/>
2<aura:attribute name="saveState" type="String" default="UNSAVED" />
3<aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.handleSaveSuccess}"/>
4
5<force:recordEdit aura:id="edit" recordId="{!v.recordId}" />
6<lightning:button label="Save" onclick="{!c.save}"/>
7Record save status: {!v.saveState}

This client-side controller fires the event to save the record and handle it accordingly.

1({
2  save: function (cmp, event) {
3    // Save the record
4    cmp.find("edit").get("e.recordSave").fire();
5  },
6
7  handleSaveSuccess: function (cmp, event) {
8    // Display the save status
9    cmp.set("v.saveState", "SAVED");
10  },
11});

We recommend using lightning:inputField for a record edit layout that uses Lightning Data Service and Lightning Design System, and provides error handling out-of-the-box.

This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce mobile app, and Aura-based Experience Builder sites.

No specifications to show