You need to sign in to do that
Don't have an account?
Michael Muchow
Refresh Lightning Web Component after Record update
Hi guys,
I have a Lightning Web Component, this component sits on the Record Page and gets the record id by import { getRecord } from 'lightning/uiRecord';
With this id and some Custom Metadata I query some data of this record by an apex class and give it back to the template to show it.
Now I want to refresh/call the apex class again to get the updated data if the record was updated.
How can I do this?
Greetings to you!
You can Refresh the Cache in LWC. Sometimes, you know that the cache is stale. If the cache is stale, the component needs fresh data. To query the server for updated data and refresh the cache, import and call the refreshApex(wiredProperty) function.
wiredProperty—A property or method annotated with @wire. To refresh a wired method, you must pass the argument the wired method receives (which is the wired value).
Please refer to the below link (scroll to Refresh the Cache section) which might help you further.
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.apex
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
thanks for your answer.
I know I can refresh the cache if I call the refreshApex() function.
My problem is I'm not sure how I can trigger this.
My LW Component does not update the record.
I want to refresh the apex call if someone updates the record via the normal record page.
Greetings Michael