2

Is there possibility to refresh the standard related list from LWC, as we can do it using $A.get('e.force:refreshView').fire() in aura?

Any alternative to "$A.get('e.force:refreshView').fire() " in LWC

2 Answers 2

3

I have used getRecordNotifyChange() function to refresh the required list of records, for more info please follow the below:

https://blog.texei.com/refresh-a-record-page-from-a-lightning-web-component-14a5874ff68e

you can also trick it with

eval("$A.get('e.force:refreshView').fire();");
2
  • I saw this blog, in that it says "getRecordNotifyChange() however can refresh existing Contacts in the related list, but will not bring new Contacts to the page.", so it will not bring new records. I can try with eval one. However, I already used the Lightning message to aura to fire the refreshview.
    – Ajay
    Mar 19, 2021 at 15:09
  • 1
    Use eval it will work. Mar 19, 2021 at 16:48
3

Starting Spring 23, you can use RefreshAPI(Beta). This is currently in BETA but if you have a preview sandbox you can try the below

To refresh it import the module as shown below

import { RefreshEvent } from 'lightning/refresh';

And to refresh the standard components simply dispatch a Refresh event like below

 this.dispatchEvent(new RefreshEvent());
4
  • Becoming GA in Summer 23 btw.
    – bpilling
    May 26, 2023 at 2:24
  • @Mohith It doesn't work when I dispatch the RefreshEvent from an LWC component that is opened by a Screen Quick Action button. Is this a bug or is it working as designed?
    – Jair
    Sep 22, 2023 at 6:46
  • 1
    Can you open another question with sample code so I can reach out? Looks like a bug or a feature miss to me.. Sep 22, 2023 at 14:50
  • 1
    @MohithShrivastava Sure, my colleague has posted a new question with the sample code for further discussion: salesforce.stackexchange.com/questions/410896/…
    – Jair
    Sep 25, 2023 at 4:16

You must log in to answer this question.

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