cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
PowerApps Staff CarlosFigueira
PowerApps 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
PowerApps Staff CarlosFigueira
PowerApps 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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Kudoed Authors
Users Online
Currently online: 278 members 5,288 guests
Please welcome our newest community members: