top of page
  • Writer's pictureGirijesh Dixit

Implement Offline working in Canvas App

The PowerApps is intended to be run from a mobile device, and no one can ensure a consistent data connection cannot always be sure.

The potential issue is network dropouts, the PowerApps allows us to store data locally, which means that we can stay to work without interruption in case lose the connection to our data source.

To implement offline working capabilities, areas like detecting a connection state, storing data locally, & allowing our app to work offline must be implemented in-app for seamless working in all conditions.

Detecting a connection state -PowerApps can detect the existence of a connection using a function that can then be used within the logic of the app i.e., Connection. Connected, this will return a Boolean value: true meaning it is connected and false meaning it is disconnected. In-app, we can also determine whether the connection is based on the device's cellular connection or whether it is using Wi-Fi. If the device uses a mobile network, it is classed as a Metered connection: Connection. Metered, this returns a Boolean value: true for a metered network or false for an alternative connection.

Working with local data – One of the key abilities that we need to build into the app to allow us to go offline is to store data locally and then retrieve it again. This feature is accomplished by using the functions of SaveData and LoadData.

For an example of data called personDetails, then the function will look like this: SaveData(personDetails, "Person") This will then generate the Person data file on the local device.

Loading data from the local cache- Firstly, we need to provide the target collection—the collection of data we're going to write to. Secondly, we need to provide the name of the data file. Thirdly, we need to provide a Boolean flag to determine whether the function will continue to run if it can't find the data file.

So, if I continue the example from SaveData where we are saving our assets, I would call the function like this: LoadData(personDetails, " Person ", true)

The following code is an example of how we can implement the offline data storage within PowerApps

If(Connection.Connected, ClearCollect(personDetails, Person);

SaveData(Connected,"local_ Person"), LoadData(colAssets,"local_ Person", true));

Happy learning!!


bottom of page