How to use onsuccess action in lightning:recordEditForm?

How to use onsuccess action in lightning:recordEditForm?

Sample Code:

Component:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" >
    
    <lightning:recordEditForm recordId="0036A00000QAY0CQAX" objectApiName="Contact" onsuccess="{!c.callSuccess}">
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="Email" />
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update"/>                          
    </lightning:recordEditForm>
    
</aura:component>

Controller:

({
 callSuccess : function(component, event, helper) {
            var params = event.getParams();
            alert(params.response.id);
 }

})

Output:

Leave a Reply