When you use Power Apps in SharePoint Online in the office you will probably not be too worried about making your app work in offline mode. What if you get started using your app on your mobile?

Need for offline apps

If you have field engineers travelling to locations with their mobile devices? Do they have a wifi or a mobile data connection available? The problem here is that they may not have the option to update the databases used by your app.

In this post I’m looking at the first steps of creating offline apps.

Connected or not

The first step is the Connection Object.

Connection.Connected  will tell you if your app is online or if it is offline. In the below example I’m checking the connection status and displaying a text depending on if the app is connected or not.

If(Connection.Connected, "Connected", "Offline")
Identifying Connected  or Offline apps Power Apps

Similar things can also be done to find out if you are on a metered connection or not.

If(Connection.Metered, "Metered", "Unlimited")
MEtered

To make this all look a bit better you could of course also use smile faces.

Smile

For an unhappy face you could use !Connection.Connected in the visibility settings for icon and maybe use a neutral face if you have a metered connection.

Saving your data with SaveData

When you are connected, things will just work and we don’t need to worry too much about being connected. If there is no connection however it will be important to store the data temporarily on your mobile device.

There are two functions that will help with this.

  • LoadData
  • SaveData

When you try to save a form you could have something as shown below. Where you first check the connection and then store the data locally using the SaveData function.

SaveData function in Power Apps

When using this on a mobile devices and you don’t have a connection the Title will be stored on the device for later use.

Getting your data back with LoadData

Now when you’re loading the app you can collect the same data using a LoadData function

Loading Screen using LoadData function

In the above example I set my default value for the title to the variable OfflineTitle.

Now that we have  looked at the basics of offline apps in PowerApps, it will be time to look at more detailed real life examples where the amount of data is larger. I will write about that in one of my future posts.


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Avatar of Pieter Veenstra

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like. I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@sharepains.com

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading