force:navigateToSObject does not display the updated data when standard Edit is overridden for a record
Last updated 2022-11-24 ·Reference W-4481240 ·Reported By 207 users
In Review
Summary
When you override the standard edit button of an object with a lightning component and after the save navigating back to the record just edited wont reflect the recent changes made.
Repro
Component (repro)
=====================
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,force:hasSObjectName" access="global" >
<aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.handleSaveSuccess}"/>
<ltng:require styles="{!$Resource.SLDS + '/assets/styles/salesforce-lightning-design-system.css'}"/>
<div class="slds-card">
<force:recordEdit aura:id="edit" recordId="{!v.recordId}"/>
<ui:button label="Save" press="{!c.save}"/>
<ui:button label="Return back to Home" press="{!c.goBack}"/>
</div>
</aura:component>
Controller:
({
save : function(component, event, helper) {
component.find('edit').get("e.recordSave").fire();
},
handleSaveSuccess : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"type": "success",
"message": "The record has been updated successfully."
});
var urlEvent = $A.get('e.force:navigateToSObject');
urlEvent.setParams({
'recordId': component.get('v.recordId'),
'isredirect': true,
});
urlEvent.fire();
},
goBack : function(component, event, helper) {
var homeEvent = $A.get("e.force:navigateToObjectHome");
homeEvent.setParams({
"scope": component.get('v.sObjectName')
});
homeEvent.fire();
}
})
Use the above component to override edit button and edit a record with some changes and save, you will observe that the recent changes are not updated on the detail page until you refresh the page manually.
Workaround
1) Use lightning:recordEditForm instead of force:recordEdit
2) Refresh the page manually to see the updated values.(Sometimes you may need to refresh multiple times.)
3) Re-edit the record and click cancel without making any new changes
Reported By (207)































































Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.