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

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

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

Worked perfectly. Thanks Carlos.

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

 

Anonymous
Not applicable

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
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,981)