Power Apps Dataverse Offline Mode For Canvas Apps

Power Apps Dataverse Offline Mode For Canvas Apps

With the all new Power Apps Dataverse offline mode it’s easier than ever to build an offline capable mobile app. I am surprised by how little coding it takes to setup. Now offline mode is mainly a configuration task. No more LoadData and SaveData functions. Granted, you’ll need Dataverse to use this method and there are limitations. But this is definitely the way of future. In this article I’ll show you how to build an offline mode for canvas apps.

Table of Contents
• Introduction: The Field Inspections AppSetup A Field Inspection Dataverse TableAllow The Dataverse Table To Be Used OfflineBuild A Field Inspections Canvas AppEnable Dataverse Offline Mode In The Advanced Settings MenuCreate A Dataverse Offline ProfileConfigure The Dataverse Offline ProfileApply The Dataverse Offline Profile To The Canvas AppInsert An Offline Status Indicator IconUnderstanding The Offline Status Indicator IconTest The Offline Cavnas App On Tablet & PhoneLimitations-Of-Power-Apps-Dataverse-Offline-Mode




Introduction: The Field Inspections App

The Field Inspections app is used by mechanics at a construction company to inspect heavy duty vehicles. Inspections are done in the field where there is not always an internet connection available so the app must be able to work offline.




Setup A Field Inspection Dataverse Table

Create a Dataverse table named Field Inspection with the following columns

  • Name (Single-line text)
  • Inspection Date (Date only)
  • Inspection Result (Choice: Pass, Fail)
  • Inspection Notes (Multi-line text)

Populate the Field Inspection Table with the following sample data:

NameInspection DateInspection ResultInspection Notes
Backhoe (#BA-92435)6/9/2023PassLorem ipsum dolor.
Bulldozer (#BU-29217)6/9/2023PassLorem ipsum dolor.
Bulldozer (#BU-30015)6/8/2023FailLorem ipsum dolor.
Compactor (#CO-67176)6/7/2023PassLorem ipsum dolor.
Compactor (#CO-97701)6/7/2023PassLorem ipsum dolor.
Dump Truck (#DU-46258)6/7/2023PassLorem ipsum dolor.
Excavator (#EX-21789)6/6/2023FailLorem ipsum dolor.
Grader (#GR-37016)6/5/2023PassLorem ipsum dolor.
Scraper (#SC-18687)6/5/2023PassLorem ipsum dolor.
Trencher (#TR-37271)6/5/2023PassLorem ipsum dolor.




Allow The Dataverse Table To Be Used Offline

Each Dataverse table in an offline canvas app must be enabled for offline use. Open the Dataverse table properties.



Check the Can be taken offline box and press the Save button.




Build A Field Inspections Canvas App

We want to focus on how to configure our Power Apps to be offline capable and not spend much time on building a custom app. Therefore, we will create an app from our Field Inspection table as opposed to starting from a blank app.

Open Power Apps studio, select Create an app and then choose Select an existing table.



Select the Field Inspection table and press the Create app button.



An app will be generated based upon the Field Inspection table we created.




Enable Dataverse Offline Mode In The Advanced Settings Menu

Power Apps Dataverse offline mode is currently an experimental feature. It must be enabled in the Advanced Settings menu before we can use it. Open the Advanced Settings menu and go to Upcoming Features. Then select the Experimental tab and toggle on the Dataverse offline setting.



Then go-to the General tab and turn on the Can be used offline setting. An auto-generated offline profile is generated by default but we will create our own custom offline profile and apply it here in a few moments.




Create A Dataverse Offline Profile

Making a custom Dataverse offline profile offers greater control over which data is brought into the canvas app. With a custom profile we can filter tables and store only the records we need offline. By comparison, an offline profile generated by Power Apps will bring in all records for every table in the app.

Go to the Power Platform Admin Center and locate the environment the Field Inspections app was built in. Then open the Settings menu.



Expand the Users + permissions menu and select Mobile configuration.



Create a new profile named Field Inspection App User.




Configure The Dataverse Offline Profile

Now that the Dataverse offline profile has been created we must select which tables and records will be brought into our app. Open the Field Inspection App User offline profile and press the Add Table button.



Add the Field Inspection table.



We can define which records we want to bring into the canvas app. In this example we will choose All Rows. But many times when designing an offline canvas app we may want to choose Organization Rows > User’s rows to download only records belonging to the user.

Once the table configuration is saved it will appear in the list.




Apply The Dataverse Offline Profile To The Canvas App

Back in Power Apps Studio we update the Select offline profile setting to use our newly configured profile. Choose Field Inspection App User from the dropdown menu.




Insert An Offline Status Indicator Icon

It is important for an offline app user to know the status of any data changes made within the app and whether they have synced from the server. Power Apps studio includes an offline app template with this pre-built feature. We can take it from the template to use for our own design.

Add a new screen using the Offline template.



The globe icon in the top-right corner of the template is the offline indicator. Copy the Globe icon from the template screen…



…and paste it into the the Field Inspections App titlebar. Delete the template screen this is done. We no longer need it.




Understanding The Offline Status Indicator Icon

The offline status indicator icon will change to reflect the current state of the app. Here is a list of all the status indicator icons and their meaning.



This Switch function is found in the Icon property of the icon. It controls which icon should be shown based on the app’s status.

Switch(Connection.Sync,
   ConnectionSync.Connected, Icon.Globe, 
   ConnectionSync.ConnectedWithWarning, Icon.GlobeWarning,
   ConnectionSync.ConnectedPendingUpsync, Icon.GlobeChangesPending,
   ConnectionSync.ConnectedError, Icon.GlobeError,
   ConnectionSync.ConnectedRefresh, Icon.GlobeRefresh,
   ConnectionSync.NotConnected, Icon.GlobeNotConnected, 
   ConnectionSync.NotConnectedWithWarning, Icon.GlobeWarning,
   ConnectionSync.NotConnectedPendingUpsync, Icon.GlobeChangesPending,
   ConnectionSync.NotConnectedSyncError, Icon.GlobeError
)



The app user may also tap the icon to get more information about the app’s status. This code is found in the OnSelect property of the icon.

Switch(
   Connection.Sync,
   ConnectionSync.Connected,
   Notify("Your device is connected to the network, and your app is ready to work offline.",NotificationType.Success), 
   ConnectionSync.ConnectedWithWarning,
   Notify(Connection.LastSyncMessage,NotificationType.Warning),
   ConnectionSync.ConnectedPendingUpsync,
   Notify("Some data on your device must be synchronized with the server.",NotificationType.Warning),
   ConnectionSync.ConnectedError,
   Notify(Connection.LastSyncMessage,NotificationType.Error),
   ConnectionSync.ConnectedRefresh,
   Notify("Your app is currently synchronizing data with the server.",NotificationType.Information),
   ConnectionSync.NotConnected,
   Notify("Your device is not connected to the network, but you can keep using this app.",NotificationType.Success), 
   ConnectionSync.NotConnectedWithWarning, 
   Notify(Connection.LastSyncMessage, NotificationType.Warning),
   ConnectionSync.NotConnectedPendingUpsync,
   Notify("Some data on your device must be synchronized with the server. Reconnect to the network to synchronize.", NotificationType.Warning),
   ConnectionSync.NotConnectedSyncError, 
   Notify(Connection.LastSyncMessage,NotificationType.Error)
)




Test The Offline Canvas App On Tablet & Phone

Save and publish the canvas app. Then open the app in Power Apps on tablet or phone.



The loading screen will indicate the app is being prepared for offline use during the initial load.



Now the Field Inspections app can be used in offline mode. When the tablet or phone is not connected to the internet it will store the changes on the device and sync them to the database once an internet connection is made.




Limitations Of Power Apps Dataverse Offline Mode

There are some important limitations to be aware of when using Dataverse offline-mode

  • No, SharePoint is not supported by this offline-mode.
  • Files & images are not currently supported in offline-mode but I assume they will be in the future since model-driven aps support it.
  • Delegation support is not yet implemented for all functions that can be delegated in Dataverse
  • Offline apps may not be built in the default environment
  • This is still an experimental feature so make sure to verify it is working as expected before deployment





Questions?

If you have any questions or feedback about Power Apps Dataverse Offline Mode For Canvas Apps please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

28 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Dean Moran
Dean Moran
10 months ago

I have built an inspections app using SharePoint as a data source. I’ve made it offline but it needs the user to connect at least once to fetch all the data needed for the app to work. Does this method overcome the need to connect? Could a user go into the field having never used the app and have access to survey questions etc?

Dean Moran
Dean Moran
10 months ago

Thanks Matthew. I tried using Wrap for that reason but it doesn’t package any data. It’s good for custom branding and proving a native app experience.

Dean
Dean
10 months ago
Reply to  Dean Moran

Do you know if the Dataverse offline mode overcomes the limitation of a user needing to open the app for the app to poll for internet connection and synch the data? I’m currently using a timer that checks for a connection and uploads the data if one is found, however this relies on the user opening the app. Ideally the app could run and check for a connection in the background. My client is very keen to use Power Apps but offline is imperative because they’re out in the back country of New Zealand with patchy Internet.

Dean
Dean
10 months ago

Thanks Matthew, that’s a cool feature. It sounds much easier to implement that messing around with SaveData, LoadData, collections and timers. I will tell the client that in order to use the Internet they need to be connected to the Internet!

Proton
Proton
10 months ago

Hi Matthew, thanks for this.

I’ve implemented the offline feature but seem to be experiencing some errors which aren’t affecting the performance but showing up nevertheless.

My app is an asset management app, linking to a database of assets and allowing users to modify asset status’ and view asset details. After implementing the offline feature, when going on the form I receive an error which says ‘error when trying to retrieve data from the network’.

Do you have any idea how I can fix this?

Dean
Dean
10 months ago
Reply to  Proton

You will receive this error message whenever anything in the app attempts to connect to the internet. For example if you use Choices(DataSource.Column) in the items property of a combobox, or O365Users to search users. As Matthew suggested, open Monitor and check all the things that access the internet.

Jason Sealy
Jason Sealy
10 months ago

Hey Matthew!
Excited to see you touching on this topic! Do you plan on writing a blog with more details on developing an app using this offline-first feature?! I would be very excited to read it and I think there is lots of potential going for it!

Thanks!

Melanie Tully
Melanie Tully
9 months ago

Would offline mode work for teams dataverse tables?

Melanie Tully
Melanie Tully
9 months ago

That’s a shame, I did think it would be the case but thank you for confirming 🙂

Ramesh Mukka
Ramesh Mukka
7 months ago

Hey Matt, as this doesn’t support images and files yet, along with Dataverse Offline feature can I still use LoadData, SaveData and ClearData functions to deal with images and files?

Obaid ur Rehman
Obaid ur Rehman
7 months ago

Great article and I can’t think of a better use for Offline Capabilities than in a Field Inspection App. However, I have a question, considering the business and field there can be so many instances where a field inspector needs to use images and save them in the offline mode, is there any way we can achieve this without using Load/Save data?

Will Page
6 months ago

Thanks for taking the time to research this and document it. Unfortunately the images are broken with 404 not found errors. Any chance you can fix them?

Last edited 6 months ago by Will Page
Dejan Trajkovic
Dejan Trajkovic
4 months ago

Thanks, Matthew, At the time that I’m writing these files are enabled but I have a problem when using relationships created in Dataverse in offline do you know if that is possible offline first? All my tables have been prepared for offline but I’m not able to leverage relationships during offline mode.

John Keelan
John Keelan
2 months ago

The Globe Icon doesn’t update when using the switch statement to update the icon.

When I go offline it still shows on the icon that I am online.