cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
duffysp 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
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
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

duffysp Advocate I
Advocate I

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

Worked perfectly. Thanks Carlos.

yayala 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
Jennie Helper I
Helper I

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (5,802)