cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Offline app - LoadData Function Indicating File Doesn't Already Exist

Hello,

 

I am trying to build a simple mechanism to my app to extend its use offline.

 

What I want to do: OnStart of the app, if there is connection, I want to save four tables to four different collections and then save those collections to my local cache. If there is no connection, I want to load those four tables into the collections.

 

What I have:

If(
// Check for connection
Connection.Connected,
// Connection - Save data to collections
ClearCollect(CollectionOne, TableOne);
ClearCollect(CollectionTwo, TableTwo);
ClearCollect(CollectionThree, TableThree);
ClearCollect(CollectionFour, TableFour);
// Save tables to local cache
SaveData(TableOne, "One");
SaveData(TableTwo, "Two");
SaveData(TableThree, "Three");
SaveData(TableFour, "Four"),
// No Connection - Retreive data from local cache & save in collections
LoadData(CollectionOne, "One", false);
LoadData(CollectionTwo, "Two", false);
LoadData(CollectionThree, "Three", false);
LoadData(CollectionFour, "Four", false);

);

 

What is happening:

I keep getting this error as if the name of the file does not exist: "There was a problem loading your data".

However, as you can see all names ("One", "Two", "Three", "Four") are matching. Is there something I am doing wrong when saving the data (SaveData)?

 

On a side note, the documentation for SaveData is not consistent/clear.

The online microsoft docs at https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-savedata-loaddata say: SaveDataCollectionName ) - Collection - Required. Collection to be stored or loaded.

In Power Apps, SaveData( source, name) - Source: A table whose contents will be saved.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Offline app - LoadData Function Indicating File Doesn't Already Exist

Hi @Anonymous ,

I have been using this function for about two years without issue and suggest the following:-

  • SaveData from the Collection - you have already queried the data, so no need to go back to it again when you have it in the app.
  • Use the true parameter on LoadData to ignore the command if the device has not yet configured the structure with the SaveData command. Not a big deal, but it will error if the phone app is opened offline first.
  • I may be stating the obvious, but you cannot test this on a PC - it has to be on a mobile device.
If(
   Connection.Connected,
   ClearCollect(CollectionOne, TableOne);
   ClearCollect(CollectionTwo, TableTwo);
   ClearCollect(CollectionThree, TableThree);
   ClearCollect(CollectionFour, TableFour);
   SaveData(CollectionOne, "One");
   SaveData(CollectionTwo, "Two");
   SaveData(CollectionThree, "Three");
   SaveData(CollectionFour, "Four"),
   LoadData(CollectionOne, "One", true);
   LoadData(CollectionTwo, "Two", true);
   LoadData(CollectionThree, "Three", true);
   LoadData(CollectionFour, "Four", true);
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

1 REPLY 1
Highlighted
Community Champion
Community Champion

Re: Offline app - LoadData Function Indicating File Doesn't Already Exist

Hi @Anonymous ,

I have been using this function for about two years without issue and suggest the following:-

  • SaveData from the Collection - you have already queried the data, so no need to go back to it again when you have it in the app.
  • Use the true parameter on LoadData to ignore the command if the device has not yet configured the structure with the SaveData command. Not a big deal, but it will error if the phone app is opened offline first.
  • I may be stating the obvious, but you cannot test this on a PC - it has to be on a mobile device.
If(
   Connection.Connected,
   ClearCollect(CollectionOne, TableOne);
   ClearCollect(CollectionTwo, TableTwo);
   ClearCollect(CollectionThree, TableThree);
   ClearCollect(CollectionFour, TableFour);
   SaveData(CollectionOne, "One");
   SaveData(CollectionTwo, "Two");
   SaveData(CollectionThree, "Three");
   SaveData(CollectionFour, "Four"),
   LoadData(CollectionOne, "One", true);
   LoadData(CollectionTwo, "Two", true);
   LoadData(CollectionThree, "Three", true);
   LoadData(CollectionFour, "Four", true);
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

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