Canvas Power Apps and Offline Use – Offline Profile

In the previous article, we quickly went through the implementation of Canvas Apps, which supports offline use. Let’s continue the theme and focus this time on optimizing the offline application.
Mobile offline profile
Canvas Power Apps that support offline uses the local database installed on the device. The application always communicates with the local database. The content of this is synchronized with Dataverse at suitable intervals.

However, the phone’s storage space reserved for Power Apps is limited. Defining which Dataverse data is transferred to the local database is crucial. This is done using a mobile offline profile.
In the example implementation, we used an automatically generated offline profile. It picks the tables needed by the application for the profile, but it does not make any restrictions. All rows of the tables are loaded to the device (up to 3 million rows).
In our example, there are more than 3000 tasks (tp_inspection) in Dataverse. There could well be hundreds of thousands of them. Mobile users hardly need all of them.

Creating profile
We want to control the amount of data transferred to the devices. To use the application, you must create your offline profile. Choose the right environment from the Power Platform administration center and mobile configuration from its settings.

Create a new profile.

And give a name for it.

This way we have an empty profile.

Offline profile configuration
Let’s proceed to edit the profile by clicking on its title. Let’s add the tables used by the application one at a time (Account, Task, Category).

The next dialog is the thing. The first part defines which items are transferred to the device.
- Rows based on their ownership (user, team, or organization)
- All rows
- Rows related to another synchronized row. For example, if a subset of accounts are transferred to the device, we can define that the primary contact of those accounts is also transferred
- Rows we define ourselves (custom)
In addition, we can define how often the synchronization is done. The default is 10 min. The shortest interval is 5 minutes and the longest is 24 hours.

Users record new tasks with the application, which can be related to any category and account. From these tables (account, category) we get all rows. In reality, we would filter out the inactive ones.
However, we want to limit the number of tasks stored on mobile devices. Select Custom and click the filter icon.

We get to define the filtering condition for tasks. We only want tasks on the device that are
- Created by the user himself or
- Have status new or work in progress or
- Created during the previous 30 days
The filter condition looks like this.

Ready! Finally, we publish the profile.

Please note that the user section of the profile (Users with offline access) is not relevant to Canvas Apps.
Finally, let’s set the Canvas app to use the new profile.

And re-publish the app.
Yes, the number of tasks saved in the phone’s database has dropped to five.

Adding an offline profile to a solution
We want to include our offline profile in the solution. The easiest way is to add the objects related to Canvas Power Apps (Advanced -> Add required objects).

And there it is.

Summary
Configuring the offline profile is an important step in the implementation of Power Apps for offline use. It ensures that the mobile device is not filled with unnecessary data. The initial synchronization on the first use is also faster when only 500 rows are moved instead of 500,000.
Complex profile filtering conditions can significantly slow down synchronization. Avoid the use of the following
- String comparison with Contains, Begins with and Ends with -operators
- Filters with the conditions behind the relations. The deeper the relationship path, the worse. E.g. “I only include customers whose primary contact person’s first name is Timo”.
If the use of the application involves photos, limiting the data that can be moved is even more important. But more about the photos in the next story.