Offline Data Sync in Power Apps: Building a Resilient Field Inspection Tool
Explore how to create canvas apps that continue working without internet access and automatically synchronize once connectivity returns.
Mobile canvas apps are often used in environments where internet access is intermittent — shop floors, remote field sites, or underground facilities. Without a robust offline strategy, users can lose data or face errors when connectivity drops. This guide walks you through building a Power App that continues to function offline, saving changes locally, and automatically pushing them to the data source once the device reconnects.
We will use a fictional Field Equipment Inspection scenario, but the same pattern applies to any business process where offline resilience is required.
Scenario: Equipment Inspection App
A team of field technicians visits client locations to inspect heavy machinery. They record the equipment ID, their name, the date, a pass/fail status, and any comments. Internet connectivity in these industrial sites is often unreliable, so the app must store inspection records locally and sync them to a central SharePoint list when a connection becomes available.
For this solution we will use a SharePoint list named Inspections with the following columns:
| Column | Type | Notes |
|---|---|---|
| OfflineID | Single line of text | Stores a GUID generated locally |
| EquipmentID | Single line of text | Unique identifier for the equipment |
| Technician | Single line of text | Name of the technician performing check |
| InspectionDate | Date and time | Date and time of the inspection |
| Status | Choice (Pass / Fail) | Inspection result |
| Comments | Multiple lines of text | Additional observations |
Populate the list with a few sample records to test the app later. Each row needs a unique GUID in the OfflineID column. You can generate these manually or use the GUID() function inside Power Apps during initial setup (we will cover that in the offline create scenario). For the walkthrough, assume the following three rows exist:
- OfflineID:
d1b2c3a4-..., EquipmentID:EXC-001, Technician:Alice - OfflineID:
e5f6g7h8-..., EquipmentID:EXC-002, Technician:Bob - OfflineID:
i9j0k1l2-..., EquipmentID:EXC-003, Technician:Alice
Step 1: Load Data into a Collection
Open Power Apps and create a blank canvas app. Connect it to the Inspections SharePoint list. In the OnStart property of the app, load the SharePoint list into a local collection.
ClearCollect(colInspections, Inspections);
This collection will serve as the offline working copy. We will also use SaveData and LoadData to persist it on the device.
Step 2: Gallery Screen – Select an Inspection
Add a new screen named GalleryScreen. Insert a Vertical Gallery and set its Items property to colInspections. The gallery will display all inspections loaded from SharePoint. When the user taps an item, we store the selected record in a global variable and prepare a form for editing.
Set(varSelectedInspection, ThisItem); Navigate(EditScreen, ScreenTransition.Fade);
Step 3: Edit Screen – Modify an Inspection
Add a new screen named EditScreen and place an Edit form (frmInspection) on it. Set the form’s DataSource to Inspections and its Item property to varSelectedInspection.
Hide the OfflineID card by setting its Visible property to false — users do not need to see the internal GUID.
Include a Submit button below the form. The button must perform three actions when clicked:
- Patch the local collection with the form data.
- Persist the collection to the device using
SaveData. - Mark the record as pending sync in a separate collection, then navigate to the saving screen.
// Update local collection with form changes
Patch(
colInspections,
LookUp(colInspections, OfflineID = varSelectedInspection.OfflineID),
frmInspection.Updates
);
// Save the entire collection to the local device
SaveData(colInspections, "localInspections");
// Track which record still needs to be synced to SharePoint
Collect(colPendingSync, {OfflineID: varSelectedInspection.OfflineID});
// Persist the pending list too
SaveData(colPendingSync, "localPendingSync");
// Go to the saving screen
Navigate(SavingScreen, ScreenTransition.None);Tip: If you let the user create new inspections offline, generate the
OfflineIDusing theGUID()function inside the form’s default value for that field. That ensures each new record has a unique identifier before the app goes offline.
Step 4: Admin Screen – Debug Mode Toggle
While building the app you do not want the automatic sync logic to run every time you preview a screen. Create an additional screen called AdminScreen and add a Toggle control named togDebug. Set its Default to false. When togDebug is true, the loading and saving screens will skip their automatic actions, letting you test the app without interfering with the offline logic.
Step 5: Saving Screen – Sync Pending Records
The saving screen performs the synchronization when the device is online. Add a label (lblSyncStatus) and a button (btnSyncActions). In the screen’s OnVisible property, trigger the button unless debug mode is active.
If(!togDebug, Select(btnSyncActions));
Place the actual sync logic inside the button’s OnSelect.
If(
Connection.Connected,
With(
{
recordsToSync: Filter(
colInspections,
OfflineID in colPendingSync.OfflineID
)
},
Patch(
Inspections,
ShowColumns(recordsToSync, "ID", "OfflineID", "EquipmentID", "Technician", "InspectionDate", "Status", "Comments")
)
);
Clear(colPendingSync);
SaveData(colPendingSync, "localPendingSync");
lblSyncStatus.Text = "All records synced successfully.";
Navigate(GalleryScreen, ScreenTransition.None);
,
lblSyncStatus.Text = "No internet connection. Records saved locally."
);Caution: The
IDcolumn shown inShowColumnsis the SharePoint auto‑generated integer. It must be included forPatchto update an existing record; otherwisePatchwill insert a duplicate. If you are only inserting new offline records, omitID.
Step 6: Loading Screen – Restore Data on App Start
When the app launches after a period of offline usage, you must load any locally saved data back into the collections. Add a screen named LoadingScreen with its OnVisible set to run the restoration automatically.
If(
!togDebug,
If(
!IsEmpty(LoadData(colInspections, "localInspections")),
Notify("Offline data restored", NotificationType.Success);
// Rebuild pending list from its own persisted file
LoadData(colPendingSync, "localPendingSync");
If(CountRows(colPendingSync) > 0,
Navigate(SavingScreen, ScreenTransition.None),
Navigate(GalleryScreen, ScreenTransition.None)
),
Navigate(GalleryScreen, ScreenTransition.None)
)
);The LoadData function restores the last saved state of colInspections and colPendingSync from the device. If there are pending records, the app will immediately try to sync them.
Performance and Security Considerations
- Storage limits:
SaveDatacan store up to 30 MB of data on the device. Keep your collections small enough to stay under that limit. UseOnStartto filter only the records the user needs offline. - Sensitive data: The data persisted by
SaveDatais stored in an app‑specific sandbox that is encrypted by the device’s operating system. Still, avoid storing highly confidential information without additional encryption. - Delegation: When you load data from SharePoint into a local collection, you must respect delegation limits (default 500 records). Use larger limits or filter the query to avoid loading unmanageable amounts of data.
- Conflict resolution: The sync pattern in this article assumes the last write wins. For multi‑user scenarios, consider adding a timestamp column and implementing conflict detection.
Common Mistakes and Troubleshooting
| Issue | Likely Fix |
|---|---|
SaveData / LoadData errors when previewing in browser | Test on an actual device or emulator; these functions do not work in the browser. |
| OfflineID duplicates after restoring from backup | Ensure GUID() is called at record creation, not reused. |
| Pending sync collection becomes empty after restart | Remember to call SaveData(colPendingSync, "localPendingSync") every time you add to the collection. |
SharePoint Patch fails with 404 on existing records | Confirm the ID column is included in ShowColumns. |
| Debug toggle does not prevent automatic navigation | Verify the toggle is in a screen that is visible before the loading/saving screen runs. |
Final Recommendation
The offline pattern presented here — local collections, SaveData/LoadData, and a pending‑sync list — is mature enough for production scenarios where data volumes are moderate and conflicts are rare. Always test on real devices under low‑connectivity conditions. For more advanced requirements (e.g., conflict detection, large datasets, Dataverse offline profiles), refer to the official Microsoft documentation.
References
- Original article: Power Apps Offline Mode: A Step‑By-Step Tutorial by Matthew Devaney
- Microsoft Learn: Offline apps in Power Apps (canvas apps)
- Microsoft Learn: Save and load data in a canvas app
Learn how small coding practices—like using descriptive names, flattening conditions, and simplifying logic—can make your apps easier to update and less error-prone.
Move past the gallery and discover the hidden patterns for validation, navigation, and smart submission handling in your data entry forms.
PowerShell unlocks admin capabilities that the Power Platform admin center simply doesn’t offer—from recovering deleted apps to blocking trial licenses. Here’s how to wield them safely.