By default, the mobile app downloads all Data Source rows during every sync. For large datasets, this can cause slow performance and high data usage.
To solve this, you can enable Incremental Updates. This tells the app to only download rows that have been changed or deleted since the last sync.
Required Database Changes
To enable this mode, you must add two specific columns to the end of your SyncData tables. The names must match exactly:
| Column Name | Data Type | Requirement | Purpose |
_lastUpdated | DateTime | NOT NULL | Tracks when the row was last modified (in UTC). |
_deleted | BIT | NOT NULL | Acts as a “Soft Delete” flag. 0 = Active, 1 = Deleted. |
How it Works
As soon as eForms Mobile Replicate detects a _lastUpdated column, it switches from “Full Download” to “Incremental Mode”:
- The mobile app sends the timestamp of its last successful sync.
- Replicate queries your table for any rows where
_lastUpdatedis greater than that timestamp. - Only those specific rows are sent to the device.
Implementation Rules
Managing Updates (UTC Only)
You are responsible for updating the _lastUpdated timestamp every time a row is modified.
SQL Tip: Always use the getutcdate() function to ensure timezone consistency across your global workforce.
The “Soft Delete” Requirement
If you are using incremental updates, do not use the SQL DELETE command. * If a row is physically deleted from SQL, the mobile app will never receive an update for that row and it will remain on the device indefinitely.
- The Correct Way: To delete a record, update the row so that
_deleted = 1and_lastUpdated = getutcdate().
Testing Workflow
We strongly recommend a “Test-First” approach:
- Apply the columns to a test database linked to a test eForms Mobile account.
- Verify that modified rows appear on the device while unchanged rows do not.
- Once verified, use your SQL scripts to apply the changes to your Production environment.
Performance Warning
If your Data Source has fewer than 500 rows, the overhead of managing timestamps may outweigh the sync benefits. We recommend Incremental Updates primarily for datasets exceeding 1,000+ rows.
Automating Timestamps with SQL Triggers
Implementing a SQL Trigger is the most reliable way to handle incremental updates. It eliminates the risk that a developer or another system will forget to manually update the timestamp during a data import or edit.
To ensure eForms Mobile Replicate always knows exactly which rows have changed, you can apply a “Last Updated” trigger to your tables. This script automatically refreshes the _lastUpdated column to the current UTC time whenever a row is modified.
Sample SQL Trigger Script
Replace [YourTableName] with the actual name of your table in the SyncData database.
Best Practices for Triggers
- Primary Key Check: Ensure your
WHEREclause targets your table’s unique identifier (usuallyId). - Bulk Inserts: If you are performing large bulk inserts (e.g., via BCP or Integration Services), triggers may be disabled by default. Ensure your import process either enables triggers or manually sets the
_lastUpdatedcolumn toGETUTCDATE(). - The “Soft Delete” Logic: When you “delete” a record, your application should run an
UPDATEcommand: SQLUPDATE [YourTableName] SET _deleted = 1 WHERE Id = 'XYZ';Because this is anUPDATE, the trigger above will automatically fire and set the correct_lastUpdatedtime for you!
Summary Checklist for a Healthy Sync
- Trigger Active: Is the trigger enabled on the correct table?
- UTC Format: Is
GETUTCDATE()being used instead ofGETDATE()? - Soft Deletes Only: Have you replaced all
DELETEqueries with_deleted = 1updates?