When you use PowerApps in SharePoint Online in the office you will probably not be too worried about making your app work in offline mode. What if you are using your app on your mobile? 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..
Similar things can also be done to find out if you are on a metered connection or not.
To make this all look a bit better you could of course also use smile faces.
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
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.
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.
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
Now when you’re loading the app you can collect the same data using a 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.