cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

How can I clear the Offline Data Cache created by LoadData?

Hi, 

Is there a method available to clear the Offline data cache created by LoadData()?

EG, I have a collection with information. On submissionI have a condition that detects if the device is offline. if it is, it uses SaveData(collection, "OfflineCache") so the data can be posted later when the device is back online.

I have a timer executing every 10 seconds. if it detects the device is Online again, it loads the data from the OfflineCache back into a collection then each item is submitted using a ForAll loop & patch commands. The collection is then cleared. -- This part works great.

 

The issue with this is that if the device stays online, The timer is triggering every 10 seconds and it loading the data from the offline cache again and again causing multiple submissions of the same data. 
Is there a command that can be used to clear the 'cache' created by SaveData similar to what Clear() does for collections?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: How can I clear the Offline Data Cache created by LoadData?

After the collection is cleared, you should call SaveData on the collection again. By doing that you'll override the previous saved data with an empty collection, effectively clearing the offline cached data.

Clear(collection); SaveData(collection, "OfflineCache")

View solution in original post

4 REPLIES 4
Highlighted
Power Apps
Power Apps

Re: How can I clear the Offline Data Cache created by LoadData?

After the collection is cleared, you should call SaveData on the collection again. By doing that you'll override the previous saved data with an empty collection, effectively clearing the offline cached data.

Clear(collection); SaveData(collection, "OfflineCache")

View solution in original post

Highlighted
Advocate I
Advocate I

Re: How can I clear the Offline Data Cache created by LoadData?

Worked perfectly. Thanks Carlos.

Highlighted
Helper I
Helper I

Re: How can I clear the Offline Data Cache created by LoadData?

Hi @CarlosFigueira,

I'm working on the same way duffysp explains on this topic, but I'm developing this app to work with a really limited connection (satellital internet on a vessel on the middle of the sea). The issue I found is when I have many records on my collection and the internet breaks in the middle of the submit process, there are records which are not loaded to sharepoint and are deleted of my collection (and cache file).

 

How can I control internet breaks or intermittence on my connection?

 

Please see my function which is on the action "onTimerEnd" of my timer:

 

If(Connection.Connected,ForAll(coleccion,Patch('Lista de sharepoint',Defaults('Lista de sharepoint'),{Title: iIncidencia, Responsable: iReporta, Fecha_x0020_incidencia: iFecha, Cabina: iCabina, Estado: iEstado, Acci_x00f3_n: iAcción, Elemento: iElemento, Subelemento: iSubelemento}));Clear(coleccion);SaveData(coleccion,"cacheCelular"))

 

Highlighted
Anonymous
Not applicable

Re: How can I clear the Offline Data Cache created by LoadData?

What I do is . 

If my local collection has five rows in it. I compare the contents of my local collection to the last 5 records, if they are the same I  don't  Patch them in,  It does add some overhead! which of course with a crappy connection isn't idea! prehaps you could store the succesful patchs  ID in local storage? 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,563)