cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
duffysp
Level: Powered On

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 Staff CarlosFigueira
Power Apps Staff

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 Staff CarlosFigueira
Power Apps Staff

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

duffysp
Level: Powered On

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

Worked perfectly. Thanks Carlos.

yayala
Level: Powered On

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"))

 

Jennie
Level: Powered On

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
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,730)