I have a Lightning Component that displays a lightning:dataTable of custom object records. Displayed fields include Name, Amount, and Date. I need the fields to be editable, but dataTable's inline editing feature doesn't support the date datatype. So instead, I've added a column with an edit button that calls the editPayment function.

editPayment: function(cmp)
        var editRecordEvent = $A.get("e.force:editRecord");
            "recordId": cmp.get("v.recordId")

That pops open the edit modal and everything is cool. But... after the record is edited, I need to load the edited data for my dataTable. My question: how do I know when the edit has been completed? Is there a way to setup a callback? Is the modal event in communications with the component that birthed it?

Update: actually, the Callback thing hadn't occurred to me until I got to the end of writing that post. After posting, I searched on editRecord callback and found some other threads -- looks like others have had the same issue.



Callback event on $A.get('e.force:editRecord') in lightning

It's some consolation to know I'm not alone on this, but neither of these threads had an answer...

What about... browser focus? After the modal closes, could I detect that browser focus has returned to my component?

  • 1
    Hit the same issue but couldn’t find a good solution. You could create an lightning component using <lightning:recordForm> and handle reload within it but it’s an additional component you have to maintain. Ideally salesforce should provide some navigation mechanism after editing the record. – Ranga Jun 16 '18 at 22:48

I ran into this exact problem and solved this using a listener like this:

<aura:handler event="force:showToast" action....>

While really ugly, you can successfully listen to a success toast fired from force:editRecord and parse it to see the message and type so you can refresh accordingly.

  • Yeah, but what if they cancel... I'm building my own component to do it. Seems a waste of effort, but no alternative. – PatMcClellan__c Jun 17 '18 at 0:22
  • But if they cancel why do you need to refresh anything? Yeah the other alternative is using lightning:recordEditForm sadly – tsalb Jun 17 '18 at 0:30
  • Good point, of course. – PatMcClellan__c Jun 18 '18 at 2:16
  • If you are using LDS , you can achieve the same with recordUpdated handler on force:recordData instead of relying on the message in toast event (salesforce might change the message). – zuke Feb 17 '19 at 22:34

Apparently there is no standard way to capture the save event from the standard force:editRecord Event - I think - Only way around this is to create a new custom component with your own custom save button. then force:recordSaveSuccess will work.

note - that with lightning:recordViewForm fields will get refreshed after save.

To maybe save some time to ppl here. This is what tried so far (last option seems to work but bit ugly ):

<aura:handler name="change" value="{!record}" action="{!c.doRefreshPage}"/>

// record does not change - no invoke to function

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

//Where it fires as Modal comes up

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

//Will be invoked after save - but multiple times - best option currently unfortunately - so had to hack it:

JS Controller

refreshAll: function (component, event, helper) {
        var eventType = event.getParam('type');
        var indexCall = 0; //making sure function not firing too many times
        if(eventType == 'SUCCESS'){
        if(indexCall == 0){
            indexCall +=1;
         var TreeGroup = component.find('TreeGroup'); //the aura:id of my component
         var auraMethodResult = TreeGroup.refresh();    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.