How to handle a record save event in salesforce lightning?

I have implemented the record edit according to instructions given in https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_force_recordEdit.htm?search_text=channel. Everything is working correctly except the recordSaveSuccess event and its handler.
Below I have included my code.{!c.save} is not called. Am I doing something wrong?

/Markup/

<aura:iteration items="{!v.openActivityList}" var="activity">
    <tr onmouseenter="{!c.showEditIcon}" onmouseleave="{!c.hideEditIcon}"> 
        <td>   
            <c:DFActivityCardCmp activity="{!activity}" uiThemeDisplayed="{!v.uiThemeDisplayed}"/> 
        </td>
        <td class="vertical-align-center iconDiv">
            <div class="slds-hide"> 
                <i aura:id="editIcon" data-id="{!activity.activityId}" class="fa fa-pencil" onclick="{!c.editActivity}"></i>
            </div>
        </td>
      </tr>
</aura:iteration>

I have embedded the lightning component in Account page with a new tab.

/Handler/

<aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.save}"/> 

/Controller methods/

editActivity : function(component, event, helper) {/**Opens edit popup**/
    var recordId = event.target.dataset.id; 
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({
        "recordId": recordId
    });
    editRecordEvent.fire();
},

save : function(component, event, helper) {/**handler method**/
    console.log("record saved");
}

Answer

force:recordSaveSuccess is used with the force:recordEdit component

<force:recordEdit aura:id="edit" recordId="{!v.recordId}" />

Attribution
Source : Link , Question Author : nilesh_ramteke , Answer Author : vignesh

Leave a Comment