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
Brooks Kreutzer 10Brooks Kreutzer 10 

How do I invalidate the built-in Lightning Data Service caching mechanism in a Lightning Web Component?

Context

I have a custom Lightning Web Component that allows modification of multiple records inside of modal. Once a record is updated, I reload that same record-id, but the old data shows up instead of the new data. After thorough research, I have concluded that the Lightning Data Service is at fault here. It is caching the data in the built-in ViewState most likely. The only way to get a data refresh is by refreshing the entire web page. I found multiple articles that explain how to turn off Secure and Persistent Browser Caching, but this is an unacceptable solution, as the entire Organization will take a performance hit, to support my little Lightning Web Component. Also salesforce insists that you don't do it production:

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/debug_disable_caching.htm

Question

How do I invalidate or send a ChangeNotify Event to the Lightning Data Service (in the context of Lightning Web Components), so my lightning-record-edit-form shows the updated data, instead of the old data (without refreshing the entire web page of course)?
jprichterjprichter
Some sample code could help us help you.