Develop offline apps with PowerApps

The PowerApps has been very popular in recent times and customers have either developed solutions or starting to develop. Based on the feedback received so far, we have decided to write series of articles related to PowerApps that will help plan your first PowerApps implementation. This article provides information on offline capability.

Microsoft’s PowerApps is a cloud-based service framework (part of office 365) that allows users to create, collaborate, share and manage custom business applications which can be integrated with other line of business applications.

PowerApps comes with connectors to consume/save data from various cloud-based services such as Office365, SQL Server, Dynamic 365, Salesforce, Twitter, Facebook etc.. or build your own connectors. Developed PowerApps solution can also be published on the web or as a mobile app usable on Windows, iOS, and Android devices.

When building mobile apps, one of the most common scenarios app makers face is how to enable their users be productive in situations where there is limited or no connectivity at all. To support this, PowerApps has been developed to work while being disconnected and to provide some support for offline data caching. Keeping this in mind Microsoft has released an offline capability to support data load/save when the application is offline.

What happens when the mobile version of PowerApps is launched when offline:

•Open PowerApps mobile player app offline

•Run App while being offline

•Determine if your app is online or offline or in a metered connection by using the Connection signal object

  • Leverage existing formulas such as LoadData and SaveData for basic data storage while offline.

Building solutions using PowerApps

First, we need to understand how PowerApps applications access external data. The primary mechanism for PowerApps applications to consume data is through a set of connectors provided by the platform such as SharePoint, Office 365 and the Common Data Service (CDS). This will also assist in building your own custom connectors (if required) that can allow you to build any custom logic and capabilities as well as run them anywhere such as using Azure Functions. Theses connectors are accessed over the internet using Hyper Text Transfer Protocol Secure (HTTPS) which means your users will need to be online for them to access this data or functions that they offer.

Offline capability with local collections

One of the most interesting aspect of PowerApps is that it offers a set of capabilities and formulas that allow you to filter, search, sort, aggregate, insert and manipulate data that is consistent regardless of the data source such as if you are using a SQL database, a SharePoint List, a Common Data Service entity, or even collections that are locally stored the device.

This allows us not only to easily build applications that can be retargeted to use a different backend but also that can be modified to use local collections instead with almost no changes to the logic. When dealing with offline data, local collections will be the primary mechanism that PowerApps offers today. The details of this local collections are provided as part of Load/Save data PowerApps functions. SaveData( Collection, Name ) LoadData( Collection, Name [, IgnoreNonexistentFile ])
Collection — Required. Collection to be stored or loaded.
Name — Required. Name of the storage. You must use the same name to save and load the same set of data. The name space isn’t shared with other apps or users.
IgnoreNonexistentFile — Optional. Boolean (true/false) value that indicates whether LoadData function should display or ignore errors when it can’t locate a matching file. If you specify false, errors will be displayed. If you specify true, errors will be ignored, which is useful for offline scenarios. SaveData may create a file if the device is offline (that is, if the Connection.Connected status is false).

In summary:

•On mobile application launch (OnVisible property)

•If online, the application will directly access the connector to fetch the data and use it to populate a local collection

•If offline, the application will load the data from a local cache using LoadData

•Application will allow the user to save data either online (post directly to connector and refresh the cache) or offline (save to local cache)

•Application checks every 5 minutes to check if the application is online

•Application will post any data that has been saved in the cache

•Application will refresh the local cache and save it using SaveData

Please feel free to contact us if you have any queries in regard to PowerApps.

About Prometix: At Prometix, we design implement and support Microsoft based technology solutions that help our client’s staff to more easily use and share information as individuals and in teams. We work with our clients to establish a structure that makes information easier to create, store, find and share with others. We’ve worked hard to understand how people want to access and share information.

Prometix intelligently design a content built on SharePoint. Prometix