Let me provide a comprehensive solution addressing all aspects of your offline sync challenges.
Offline Data Capture Architecture:
Implement a robust versioning system in your CDT structure. Add these fields to your inspection data type:
version: Number (Integer)
lastModified: DateTime
modifiedBy: Text
When the mobile form loads, capture these values and store them in hidden fields within your offline-enabled form.
Conflict Detection Strategy:
Your integration object should implement proper ETag handling. Configure the web API to:
- Generate ETags based on version + lastModified timestamp
- Validate incoming If-Match headers against current record state
- Return 409 only for genuine conflicts (different modifiedBy or version mismatch)
The key is distinguishing between stale client data and actual concurrent modifications. Implement this logic in your save process model:
a!localVariables(
local!currentRecord: rule!GetInspectionById(ri!id),
local!hasConflict: and(
local!currentRecord.version <> ri!clientVersion,
local!currentRecord.modifiedBy <> ri!currentUser
)
)
User Feedback on Sync:
Implement a three-tier feedback mechanism:
- Immediate Success: Show green checkmark for successful syncs
- Soft Conflicts: For same-user modifications (user edited on web while offline), auto-merge with notification
- Hard Conflicts: For different-user modifications, present conflict resolution UI
Create a conflict resolution interface in your mobile app that displays:
- Server version (with timestamp and modifier)
- Local version (with offline capture time)
- Field-by-field comparison highlighting differences
- Merge options: Accept Server / Keep Local / Manual Merge
Integration with Master Data:
The 409 errors often stem from referential integrity issues with master data. Implement these safeguards:
- Cache master data locally when going offline (lookup lists, reference data)
- Validate foreign key references before sync attempt
- Implement a pre-sync validation service that checks:
- Referenced records still exist
- User still has permissions
- No schema changes have occurred
ETag/Versioning Implementation:
Modify your REST endpoint configuration:
Request Headers:
If-Match: "{version}-{timestamp}"
Content-Type: application/json
Response Headers (on success):
ETag: "{newVersion}-{newTimestamp}"
Last-Modified: {serverTime}
Reducing False Positives:
Implement these specific fixes:
- Timezone Standardization: Convert all timestamps to UTC at the data layer
- Grace Period Logic: Allow syncs within 300 seconds if same user
- Optimistic Locking: Use version numbers instead of timestamps for conflict detection
- Idempotency Keys: Generate unique sync IDs to prevent duplicate submissions
Testing Recommendations:
Create test scenarios covering:
- Same user, multiple devices, offline edits
- Different users, concurrent modifications
- Network interruption during sync
- Timezone edge cases (DST transitions)
- Master data changes while offline
Implement these changes incrementally, starting with version field addition and ETag validation. This should reduce your conflict rate from 30% to under 5%, with remaining conflicts being genuine concurrent modifications requiring user resolution. The key is making conflict detection intelligent rather than overly cautious, while providing clear user feedback when intervention is needed.