3

This question is pretty much the same as related list not getting updated in Salesforce Lightning from 2 years ago. That doesn't have an accepted answer and has a comment that suggests one answer may not work.

(Note that our aim is to be Lightning Ready for now rather than to do a rewrite of a lot of Visualforce in Lightning Components. One reason is that we have a substantial installed base who want to continue working in Classic.)

The override of the "New" action to use a Visualforce page works in Lightning Experience and returns to the parent page correctly. But the "Related" list is not updated to include the newly created object. Without the override, the platform correctly refreshes the "Related" list.

Does anyone have a reliable solution to this problem? Do I need to start thinking about firing Lightning Events from the Visualforce pages?

PS

Some more Googling has led me to this known issue Data updates are not reflected in UI after a Visualforce+Apex update in Lightning Experience reported by 530 users and more than 6 months old. That relates to the details not the related list, but a fix may address both. For now though, any workarounds?

2
  • I have a came out with the same problem, what I have done is render my button based on the different theme and used Sforce.one.back(true) and Sforce.navigatetosobject together oncomplete. It makes me sure to give the refreshed view always. Sep 5, 2018 at 18:00
  • Not exactly the same, but we had come across a similar situation, which made to a known issue, while overriding "Edit" button on a record. And that we were using force:navigateToSObject to navigate back to the record. I would imagine this to be something similar to that.
    – Jayant Das
    Sep 5, 2018 at 18:21

1 Answer 1

2

Not sure I'd recommend this approach, but I ended up making a super simple Lightning component that I put on the record page that calls e.force:refreshView on component load. This forces a reload of the cache of the page on load, and makes sure it is up-to-date after any Visualforce pages have done some updates.

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <lightning:button onclick="{!c.doInit}" label="Refresh" title="Refresh"/>
</aura:component>

controller:

({
    doInit : function(component, event, helper) {
        $A.get('e.force:refreshView').fire();
    }
})
3
  • How do you avoid infinite regress? Doesn't refreshView force everything including the Lightning components on the record page to reload?
    – Charles T
    Sep 5, 2018 at 19:34
  • No, it only refreshes once. Sep 5, 2018 at 19:59
  • I like the solution mostly. However, when I tried it verbatim just now, the refresh did not take. However, if you include a window.timeout () [500 ms works for me] in doInit, the refresh happens. Oct 23, 2019 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .