cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
T_R_O_N
Advocate II
Advocate II

How can I use SaveData to temporarily hold collections between app restarts?

Hi, I’m currently working on an app for my company to keep track of the amount of time that our employees are working for our clients. Unfortunately, I’ve hit a rather big speed bump, the app needs to be able to collect information without an internet connection, and then upload that information to the data base later. I need to get Powerapps working offline…

So far I’ve figured out most of the puzzle, but I’m stuck on one crucial point, the app needs to be able to store the information after being exited, and opened again. I thought of using SaveData and LoadData to just save the collection that I’m working with, and then uploading that collection when there’s an internet connection again. But so far, somewhere between saving, and loading my data, everything gets duplicated. It’s quite an annoying problem, and I’m having a hard time figuring it out.

 

When the app starts, I run this code, inorder to remove any extra information that could possibly be in the collection, and then to add previously saved data to that collection.

Clear(oflne_time_sheet);
LoadData(oflne_time_sheet, "oflne_t_sheet");

 

Next in the event where a new job has been logged, and there is no internet connection, this code gets run:

 

If((!(Connection.Connected)||First(status).oflne)&&valid_c&&valid_jt, Collect(oflne_time_sheet, new_work_entry_form.Updates));

 

Finally, when the app returns to the main screen, it simply saves the collection to the file and it uploads the collection to the data base if there is an available connection:

f(Connection.Connected&&!(First(status).oflne)&&!(IsEmpty(oflne_time_sheet)), Collect(master_time_sheet, oflne_time_sheet));
If(Connection.Connected&&!(First(status).oflne)&&!(IsEmpty(oflne_time_sheet))&&First(upload_success).success, Clear(oflne_time_sheet)
SaveData(oflne_time_sheet, "oflne_t_sheet")

 

Clearly I’m doing something wrong, but I don’t know what, so maybe you guys can spot what I’m missing.

I’d greatly appreciate any help help!

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for the comming back to me! I managed to figure it out, I was uploading my collection to the data source, but not always clearing the collection afterwords, so the same fields would appear multiple times. So it was a mistake on my part that I missed that was giving me trouble. Smiley Very Happy

 

Although I did notice a few issues with the ways that SaveData, and LoadData work, which make the process of giving an app offline functunality harder than it needs to be. Also, from what I understand those two functions are the only functions that allow you to have dynamic information saved locally on the device, am I correct? 

View solution in original post

5 REPLIES 5
v-yamao-msft
Community Support
Community Support

Hi T_R_O_N,

 

I have seen a thread about “Does the PowerApps solution have capability for offline working”, Staff @CarlosFigueira has provided some suggestions on this issue, please check this link:
https://powerusers.microsoft.com/t5/PowerApps-Forum/Does-the-PowerApps-solution-have-capability-for-...

 

And also there is an idea on PowerApps Ideas Forum about Offline mode, you could comment and vote this idea at here:
https://powerusers.microsoft.com/t5/PowerApps-Ideas/Offline-mode/idi-p/825#comments


Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the comming back to me! I managed to figure it out, I was uploading my collection to the data source, but not always clearing the collection afterwords, so the same fields would appear multiple times. So it was a mistake on my part that I missed that was giving me trouble. Smiley Very Happy

 

Although I did notice a few issues with the ways that SaveData, and LoadData work, which make the process of giving an app offline functunality harder than it needs to be. Also, from what I understand those two functions are the only functions that allow you to have dynamic information saved locally on the device, am I correct? 

Hi T_R_O_N,

 

I am glad to hear that you have figured it out. Thanks for sharing the result with me.


About SaveData and LoadData function, please check this documentation for a reference:
https://powerapps.microsoft.com/en-us/tutorials/function-savedata-loaddata/

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I am currently using the SaveData function, and it saves and loads all my data fine (at first was duplicating but seems to be ok now, not sure what I did) I am using a patch function to edit entries and then overwrite the original entry, how do I do this using the SaveData/LoadData function?

Hi @jamaicavailima 

Can i have your formula?
I have similiar problem in here. And hope you can help.

 

Thanks,

pytbyt

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,809)