[SalesForce] Navigating to record detail page after edit does not reflect new data

After we update a record and navigate to a detail page, it still shows the old data.

Steps:

  • Overridden edit button of Account with a Lightning component.
  • Also used a Visualforce page with lightning out to host the component as an override, but still have same issue.

Note: Navigation issue is in 2 places:

  1. Lightning Component: Using e.force:navigateToSObject
  2. Visualforce using lightning out: sforce.one.navigateToSObject

It looks like there is some caching issue after redirect.


To resolve this, I also turned off the cache as mentioned in this question, it didn't help: Lightning Experience: How to prevent the display of obsolete data?

Question is similar to Values are not updated in Lightning after record update but it does not have a proper answer.

I also know there is a known issue: Data updates are not reflected in UI after a Visualforce+Apex update in Lightning Experience. My scenario is different as it has a lightning component.

Please let me know if anyone else is facing similar issue; as this is most common use case to use a Lightning component or Visualforce for overriding standard button's action.

My code is pretty basic to just show the existing Account name with save button, can provide if required.


What I tried for navigation:

Iteration 1:

var navigationSObject = $A.get("e.force:navigateToSObject");
navigationSObject.setParams({
    "recordId": component.get("v.recordId")
});
navigationSObject.fire();

And using sforce.one.navigateToSObject when a VF page is used using Lightning out.


Iteration 2 (as per question: Values are not updated in Lightning after record update):

var navigationSObject = $A.get("e.force:navigateToSObject");
navigationSObject.setParams({
    "recordId": component.get("v.recordId")
});
$A.get('e.force:refreshView').fire();
navigationSObject.fire();

Best Answer

Used window.location as mentioned in the comments which opens the salesforce app inside child container/page.

Finally ended up using window.parent.location as below (instead of using $A.get("e.force:navigateToSObject") or sforce.one.navigateToSObject for Lightning component or VF page respectively.) -

window.parent.location = '/' + recordId;

Not sure if this is completely supported by Lightning but works for now.


Added:

  1. Tested and this works in Lightning UI when standard button is overridden:

    • Directly with Lightning component
    • Indirectly via Visualforce using Lightning out
    • When component is used in app builder.
  2. I have disabled toast message, showing a success message via toast is weird as message appears following by redirection.

Related Topic