custom-loader
Tech Expo Gujarat - 2024

How to Store Files and Images in Dataverse with Offline Access in Power Apps

How-to-Sync-Files-and-Images-in-Power-Apps-Offline-Mode-with-Dataverse

In today’s fast-paced world, mobile applications must provide seamless functionality, even when users are offline. Power Apps, a powerful low-code platform, offers robust offline capabilities that allow users to work with files and images without an internet connection.

This blog post will explore how to configure offline support for files and images in Power Apps, focusing on syncing with Dataverse tables.

Understanding PowerApps Offline Support for Files and Images

Power Apps provides the ability to work offline by caching data, including files and images, on the user’s device. This allows users to seamlessly continue tasks like filling out forms, capturing photos, or uploading documents while the app is offline. Once the user is back online, Power Apps automatically synchronizes the data with Dataverse.

Enable Offline Access for Files and Images in Power Apps

To enable offline access to files and images, we need to configure our Power Apps environment and set up a mobile offline profile. Let’s deconstruct the process step by step.

Prerequisites: Create a Mobile Offline

  1. Access the Power Platform Admin Center: Sign in with admin credentials.
  2. Select the Environment: Choose the environment where offline access needs to be configured.
  3. Open Settings: Click on Settings in the menu bar.
  4. Mobile Configuration: Under Users + permissions, select Mobile configuration.
  5. Create or Edit a Mobile Offline Profile: Either choose an existing profile or create a new one to begin configuring offline access.

Mobile offline profile - Microsoft

Image source:  Mobile offline profile – Microsoft

Syncing File and image Attachments in Power Apps

1. Add Attachments to Power Apps

To add the Attachments Controls to Your Power Apps Form

Open PowerApps Studio:

  • Go to Power Apps Studio and open the app where you want to add file and image attachments.

Add the Attachments Control:

  • In the form’s data panel, add an Attachment field by selecting Add field.
  • Choose the appropriate Attachment fields and add it to the form.

Configure Attachments:

  • In the Properties pane, ensure that the control is linked to the correct table field where attachments should be stored (e.g., Tasks or a custom table).

2. Configure Dataverse to Store Attachments

To Enable the Attachment Field in Dataverse

Go to Dataverse:

  • Open the Power Platform Admin Center and navigate to Dataverse.

Select Your Table:

  • Choose the table where you want to store the attachments (for example, Tasks, Leads, etc.).

Add a Custom Attachment Field:

  • Go to the Columns section and click  Add Column.
  • For file attachments, select the File data type for the new column.
  • For image attachments, select the Image data type for the new column.
  • Save your changes to the table.

Notes:

  • Each attachment field can store only one attachment. To store multiple attachments, create multiple custom fields.
  • An offline profile can contain up to 14 attachment columns across all entities, so we must be mindful of this limitation to ensure app functionality offline.

3. Enable Offline Support for File Attachments in Power Apps

To ensure that your file attachments are available offline in the mobile app, we need to configure the Offline Profile and enable the File Attachment table.

 Add File Attachment Table to offline profile:

  • In the mobile configuration, select the File Attachment table. This will allow your files to be downloaded and stored on the mobile device.2.  Select Rows for Offline Access:    
  • Under Choose the rows you want to make available offline, select Related rows only.
  • Expand Relationships and select the Column name for each column where the Data type is set to File.
  • For example, if your table has a file column called MyFile, select Column name: MyFile from the appropriate table (e.g., DemoTable3).

File relationship - Microsoft

Image source: File relationship – Microsoft

Save your changes

  • Click Save to save the offline profile settings.

However, here’s the catch

While this works flawlessly in a browser, issues arise in the mobile version of the app. You can attach images to tasks on a mobile phone, but once you edit the task later, the images will disappear.

Why Do Images Disappear?

Images attached in Power Apps are stored in the Image Descriptor table in Dataverse. The problem is that these images aren’t available in offline mode of the app unless we explicitly add the Image Descriptor table to the offline profile. If the Image Descriptor table is not part of the offline configuration, images won’t be accessible when the app is offline, causing them to disappear when you edit the task.

1. To Add Image Descriptor Table to Offline Profile

To Add Image Descriptor Table

  • In your mobile configuration settings, navigate to the Data available offline section.
  • Click Add table and from the available tables, select Image Descriptor and click Next.

Add image table - Microsoft

Image source: Add image table – Microsoft

2. Choose Rows to Sync Offline

  • Under Choose the rows you want to make available offline, select All rows . This option ensures that only the rows related to your images are downloaded, optimizing the storage on the device.

Expand Relationships:

  • Expand the Relationships section to define which columns will be synced.

3. Select Image Columns:

From the list of available columns, select the Column name for each column that has the Data type set to Image.

  • For instance, if your app has image columns in DemoTable1 and DemoTable3, select the appropriate column names from these tables.

Note: In some cases, the columns may appear as unnamed in the list, but you can still select them based on the related tables.

Image Relationship - Microsoft

Image source: Image relationship – Microsoft

4. Save the Configuration

After selecting the required image columns, click “Save” to apply the changes to your offline profile.

Conclusion

Configuring offline capabilities in PowerApps ensures users can continue their tasks without disruption, even without internet access. By syncing files and images with Dataverse, Power Apps offers seamless offline functionality, improving efficiency and user experience. Once back online, the data syncs automatically, making the app both reliable and adaptable to various work environments.

Recent Post
hire now

Ready to work together?

Let's discuss your product goals and see how we can help.

join our team