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: SaveData( Collection, Name ) - Collection - Required. Collection to be stored or loaded.
In Power Apps, SaveData( source, name) - Source: A table whose contents will be saved.
Thanks
Solved! Go to Solution.
Hi @Anonymous ,
I have been using this function for about two years without issue and suggest the following:-
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.
Hi @Anonymous ,
I have been using this function for about two years without issue and suggest the following:-
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.
I have the same issue. Same code follow the pattern to savedata once online, and loaddata when offline. The code works on one app, but in another app, the cache file is not created. Has anyone experienced the same issue and found a solution?
Hi @RebekahWang ,
One clarification here - are you trying to get the data saved in one app to load in another ? If so, this will not work as they are actually different files behind the scenes.
Hi WarrenBelz,
I am running the same code (collect,savedata,loaddata) on two separate apps, which will savedata to each app's local cache(same cache name but I think that should be fine, since the scope is own app). The first app can get the data from its cache, but the second app does not have any data in the cache.
Hi @RebekahWang ,
I am not sure how to respond further - the same code should work in any app.
Thank you @WarrenBelz , and I am using the first app to test the offline function code, and the second app is an existing app which are going to have the offline function using the verified offline code in the first app.
I assume you are testing this on a mobile device, or on the Windows App with this turned on
I tested this on Mobile app and the feature you highlighted is on definitely.
I am not sure whether other app setting features will affect the cache. Since I turned on the following two features once, and tested the second app then it shows the data from cache, after I turned off/on these two features again, it never get the cache data any more. Seems some issue with app settings, but could not reproduce now.
User | Count |
---|---|
246 | |
103 | |
82 | |
49 | |
42 |