[SalesForce] Callback event on $A.get(‘e.force:editRecord’) in lightning

I'm using $A.get('e.force:editRecord') to display standard lightning edit modal window. I want to refresh my component after user saves the given record.

However there are no callback events documented by salesforce on record save success for e.force:editRecord.

By using chrome Lightning inspector tool I found two events getting fired when I clicked on Save button.

1. force:recordChange (Application Event)
2. force:save (Component Event)

I declared an application event handler for force:recordChange

<aura:handler event="force:recordChange" action="{!c.handleRecordChange}"/>

Got following error

[ERROR]: No EVENT named recordChange found: Source

To handle component event force:save I have to specify event name

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

How do I notify custom component when user saves the record.

Best Answer

You can inject your handler by using

component.addEventHandler("force:recordChange", component.getReference("c.handlEvent"));

It will work, but you can't prevent any 'default' phase events that you will catch

Related Topic