web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / saving offline records
Power Apps
Unanswered

saving offline records

(0) ShareShare
ReportReport
Posted on by

Hello,

I am trying to save records while working offline, so that they get uploaded at the end of the day to my Sharepoint list when back online.

In my edit form, I create a collection with the info entered, save it to the phone's cache, and load the data which I display in a gallery.

Collect(offline_record,{date: DataCardValue22.SelectedDate,centre: Dropdown3.Selected.Value});
SaveData(offline_record,"offline_record_local_storage");
LoadData(offline_record,"offline_record_local_storage")

I created a gallery where I display the collection by setting the items property to offline_record, and it works. 

However, when I enter a new offline record, it replaces the previous one, instead of adding it up.
So my gallery always displays the last offline record entered, instead of the whole list of offline records.

If anyone has some advice that would be great.

Thanks a lot

Categories:
I have the same question (0)
  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at
    I wouldn't reload the data from cache in one step, it's probably not finishing the write to save before loading so It's loading the first one. Use Load on app start but not during the save. See if this helps at all.
  • Community Power Platform Member Profile Picture
    on at

    Thank you for your help.

     

    I broke the instruction in 2 steps: I do the Collect and the SaveData in one button.

     

    And then I come out out of the app and on open I lood the data from the cache.

     

    However I still get the same error.

     

    It seems like when I save a new record it overwrites the previous in the cache....I don't know where I got it wrong

     

     

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at
    Anyway to post your code? Sure you don't have any odd characters on the files? I pulled my hair out once and found out the files are case sensitive and I had one letter caps on save vs my load one.
  • Community Power Platform Member Profile Picture
    on at

    Thanks,
    That's the code in the 1st button:

     

    If(Connection.Connected,

    If(Or(IsBlank(DataCardValue23),IsBlank(DataCardValue24),Value(Text(DataCardValue23))>30,Value(Text(DataCardValue23))<1,Value(Text(DataCardValue24))<70,Value(Text(DataCardValue24))>160),
    UpdateContext({popup:true}),
    SubmitForm(Form1);
    Navigate(screen_welcome,ScreenTransition.None)),

    Collect(offline_record,{date: DataCardValue22.SelectedDate,centre: Dropdown3.Selected.Value,bag: DataCardValue23.Text,sample1: DataCardValue24.Text,sample2: DataCardValue25.Text,sie: ListBox1.SelectedItems.Value,route: DataCardValue2.Text});


    SaveData(offline_record,"offline_record_local_storage"))

    And then, on open of the app:

    LoadData(offline_record,"offline_record_local_storage")

     

  • seadude Profile Picture
    1,855 on at

    Hi @Anonymous. I see your code here. You can disregard my request in your other post. Here are some ideas that may help debug your issue:

    1. Ensure all your comparisons are correct.
      1. Put some debugging labels in your app that show the status of your comparisons.
      2. Example: Create a label with Text Property set to IsBlank(DataCardValue23). Make sure its accurate. Repeat this for all your comparisons.
    2. I've found quite few times that things are not always cut and dry with IsBlank. Depending on how you setup your options or the type of control, you may need to use = " " or IsEmpty. 
    3. Also < and > comparisons can get weird when you are converting things to Text then Value(), etc.
    4. Another idea is to put debug Gallery on the screen with its Items set to the LoadData() Collection. This will tell you what the data is on your mobile phone. It can be tricky to debug Load/SaveData() without this.

    Good luck!

     

  • Community Power Platform Member Profile Picture
    on at

    I followed your advice but it's still not working.

    it just seems that I constantly overwrites the collection, instead of adding a new reocrd to the collection.

    How can I get support on that? Im hitting a wall here.

     

    Thanks

  • seadude Profile Picture
    1,855 on at

    Hi @Anonymous. So, all of your comparisons are correct? What does the Gallery show before and after you SaveData()? What does it show after you LoadData()?

  • Community Power Platform Member Profile Picture
    on at

    Hi Seadude,

     

    So i enter my record.

    After i save, the records shows in the gallery which display the collection.

    it is in the cache and then I load it to the collection. 

    It appears on the unsaved_screens I have

     

    Then I go out of the app. 
    Still offline, I want to enter a 2nd record.

    I save it, and it shows in the collection
    I load it, and then, on the unsaved_screen, I can see that this 2nd record has overwritten the first one.

    THat's my problem. At the end of the day working offline, I would like to have all my records saved on the phone, when I get to a place with wifi, i can upload all those records to my Sharpeoint list.

    I hope it's clear, let me know if you need any other info,

     

    Thanks a lot for your help

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at
    In my App, I use a separate collection that holds "changes" for uploading. Then have an upload screen that sends these to my data source. When I create any new records, I patch to my app collection and then to the changes collection and savedata() on both. Then when Online I use a forall using the addition collection to patch the changes to the online datasource. I only use Loaddata() to start the app up. This way no matter what, my changes collection won't get overwrote or be used in any way, and I can loop through just the additions into the data source. But luckily for me I only have additions, no edits / deletes, this complicates things a bit more :).
  • Community Power Platform Member Profile Picture
    on at

    But when you enter another record, doesn't it overwrite your previous record in your separate collection?

    What I don't understand, is that it the collection and the cache are disposed off when the app is off. how can i ever have a list of records in my collection? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard