function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken Koellner @ EngagewareKen Koellner @ Engageware 

Refresh LIghtning detail page after visualforce edit page

We have a legacy VisualForce page that overrides the standard Edit button.  So, in Classic or Lightning, when you press the Edit button on the record Detail page, the VF page comes up.  There is one glitch when in  Lightning Experience. When you save from the Edit page, you end up back on the Lightning Detail page but the old data (which must be in the Lightning cache somewhere) is still shown.  You have to manually refresh to get the latest data.

I'm wondering if there's any kind of trick when leaving the VF page to go back to Lightning and force it to reload.  I can't find any way to do it by passing back any sort of PageReference, with or without redirect.

Maybe there's some kinda of trick where it can go back to the VF page and the VF page could have an onComplete script that would somehow force lightning to reload the record.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Ken,

Have you mentioned if this issue is occurring in only after the recent update or it has been the same since before the update?

Looking forward for your response.

Regards,
Anutej
Ken Koellner @ EngagewareKen Koellner @ Engageware
  1. I'm looking at a record in Lightning and the phone number says "555-1234". 
  2. I press the Edit button (which is overridden with a VF page that has a controller extension).
  3. The VF page replaces everything on the desktop except the header, i.e, the tabs for the various objects and everything above that stays in place and everything below is the VF page.
  4. I change for phone number on the edit page to "555-4321" and Save.  (The controller will return a page reference back to the record that was edited.)
  5. The VF page goes away and the main body of the page below the header is back on the Lightning Detail page for the record.
  6. The phone number shown is still "555-1234".
  7. If I hit browser refresh, the page is reloaded and only then do I see "555-4321".
ANUTEJANUTEJ (Salesforce Developers) 
Yes I understood the issue but I was checking if this is something you are facing recently or if this is something that you have been observing previously as well to see if there are any issues due to latest update.
Ken Koellner @ EngagewareKen Koellner @ Engageware
It's always been that way.  I think it's just the way Lightning is.  It doesn't refresh it's data unless something in Lightning tells it to.

I have a newer feature I wrote in an Aura component that runs as a QuickAction in Lightning and in a Lighting App inside a VF page in Classic.  I found a wizz-bang solution for that.  It checks the theme and in Lightning, fires a refresh event (and toast), in classic, it redirects to the page layout.  See the code below.  That works great

What I need is the reverse solution for a VF page that overrides Edit.

Below works great of an Aura component used in both Lightning and Classic.
closeSuccess : function(component, event) {  
        var theme = component.get("v.theme");  
        if (theme=='Theme3') {
            window.location.replace("/" + component.get("v.recordId"));
        } else {
            $A.get('e.force:refreshView').fire();  // Only in Lightning, refresh.
            $A.get("e.force:closeQuickAction").fire();  // Only in Lightning, close quick action.
            var showToastEvent = $A.get("e.force:showToast");
            showToastEvent.setParams({
                'title' : 'Appointment Saved',
                'message' : 'Appointment has been saved.'
            });
            showToastEvent.fire();
        }
    }

 
ANUTEJANUTEJ (Salesforce Developers) 
I overrode the edit button with a simple lightning component and I was able to successfully getting saved and on saving it is being redirected to the record detail page where the edited values seem to be showing with the new values, I used the code from : https://gist.github.com/afawcett/d510e2d7a25daaf8b8ea9e96bbd3b4e0
I was using lightning component as you have said that this is happening with lightning components as well.