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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Save Data after discon...
Power Apps
Answered

Save Data after disconnection

(0) ShareShare
ReportReport
Posted on by 40

hi everyone, i have created a Canvas app, the interaction is between the Power apps collections and the sharepoint list, I wanted to add a feature, which makes that if a user is entering their data in the gallery, and that he disconnects or closes the page of his application, when he reconnects, that he can find himself where he left off before the disconnection. Thank you

Categories:
  • BCLS776 Profile Picture
    8,994 Moderator on at

    Hi Peter,

    Power Apps does have some basic functionality to deal with offline data saving, but only for data stored within internal collections. See documentation. To make this work well, your app must be set up to frequently SaveData() before a user might exit or abandon the app; otherwise, they will experience data loss. As well, the Power Apps functionality is limited in that if the user was working offline, they will need to re-open the app in order to activate any uploading code you build into it.

     

    Another way to handle your solution, if working offline is not the primary purpose: Save your user's app state to Sharepoint. In other words, save enough data (perhaps to a separate SP list) that the app can read it upon a later start and have it available again to the user. I've done this with user preferences, and it works well.

     

    Hope that helps,

    Bryan

  • Peter_93 Profile Picture
    40 on at

    Thank you Sir, this savedata syntax must be entered when creating the application or it is the users who must enter it ?, and also as my code below indicates, I must add the formula after this code ?, because on the documentation, we put it on the ON SELECT function, and on my code, it's on onselect. Thank you  inventaire.jpg

  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    As the maker of the app, you have to set up everything to do with working with collections, data sources, and any offline saving/retrieving of data.

     

    Your code above references a collection (ColInventaire) and an external data source (Inventaire). It is saving data from the collection as new records to the external data source. I don't know the overall user experience and process of your app, but what should happen here if the user is not connected to the internet? Instead of using Patch() to save the collection records, should you instead save that data to the device? If so, I would structure it more like this:

    If(CountRows(ColInventaire) > 0;
     If(Connection.Connected;
     ForAll(ColInventaire;
     Patch('Inventaire'; Defaults('Inventaire');
     { // Insert your Patch records here
     }
     )
     );
     SaveData(ColInventaire;"MyData")
     )
    );;
    Clear(ColInventaire);;
    
    

    This code saves the data when there is no internet connection to complete a successful Patch(). Most importantly, it saves the data before Clear() erases the collection. This code only saves the data; it does not automatically Patch() it back to the external data source once an internet connection is reestablished - you will need to set that up.

     

    Only collections can be saved using the SaveData() function and you will need to decide which logical points in your app you need to save (and later load) data. 

     

    Hope that helps,

    Bryan

  • Peter_93 Profile Picture
    40 on at

    Thank you so much Sir ,it is well explained, thank you very much and if I understand correctly according to the documentation it works only on the Mobile version? 

  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    @Peter_93 wrote:

    Thank you so much Sir ,it is well explained, thank you very much and if I understand correctly according to the documentation it works only on the Mobile version? 


    That is correct - the offline capabilities are available only for mobile devices accessing the app through the Power Apps Mobile launcher. Any device using a web browser, mobile or not, will not be able to use the offline capabilities.

     

    Regards,

    Bryan

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard