eForms Mobile Replicate – Optimizing Large Datasets with Incremental Updates

eForms Mobile Replicate – Optimizing Large Datasets with Incremental Updates

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 NameData TypeRequirementPurpose
_lastUpdatedDateTimeNOT NULLTracks when the row was last modified (in UTC).
_deletedBITNOT NULLActs 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”:

  1. The mobile app sends the timestamp of its last successful sync.
  2. Replicate queries your table for any rows where _lastUpdated is greater than that timestamp.
  3. 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 = 1 and _lastUpdated = getutcdate().

Testing Workflow

We strongly recommend a “Test-First” approach:

  1. Apply the columns to a test database linked to a test eForms Mobile account.
  2. Verify that modified rows appear on the device while unchanged rows do not.
  3. 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.

Sample JSON body
CREATE TRIGGER trg_UpdateSyncTimestamp
ON [YourTableName]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
UPDATE [YourTableName]
SET _lastUpdated = GETUTCDATE()
FROM Inserted i
WHERE [YourTableName].Id = i.Id; -- Assumes 'Id' is your Primary Key
END;
GO

Best Practices for Triggers

  • Primary Key Check: Ensure your WHERE clause targets your table’s unique identifier (usually Id).
  • 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 _lastUpdated column to GETUTCDATE().
  • The “Soft Delete” Logic: When you “delete” a record, your application should run an UPDATE command: SQL
    UPDATE [YourTableName] SET _deleted = 1 WHERE Id = 'XYZ'; Because this is an UPDATE, the trigger above will automatically fire and set the correct _lastUpdated time 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 of GETDATE()?
  • Soft Deletes Only: Have you replaced all DELETE queries with _deleted = 1 updates?
    • Related Articles

    • eForms Mobile Replicate – FAQs

      General & Branding What database types does Replicate support? Replicate currently supports Microsoft SQL Server. We are actively working to expand compatibility with other database engines in future updates. Can I white-label Replicate with my own ...
    • eForms Mobile Replicate – Running in Microsoft’s Azure cloud hosting

      Hosting eForms Mobile Replicate on Azure is a popular choice for scalability. While the core installation process remains the same as an on-premise server, there are specific networking and database considerations unique to the Azure ecosystem. Azure ...
    • eForms Mobile Replicate – User-Level Data Filtering

      By default, eForms Mobile Replicate sends every row in a table to every user. To ensure users only see the data relevant to them, you can implement User-Level Filtering. This article is an extract from the Replicate Installation Guide (PDF). For full ...
    • eForms Mobile Replicate – Seamless Data Synchronization

      While our platform offers “baked-in” cloud connectors and a robust Integration API, we recognize that many organizations have a foundational requirement: accessing data within their own local SQL environment. Replicate is a standalone web application ...
    • eForms Mobile Replicate – Push Form Entry Data to your Database

      How Data is Structured in eForms Mobile Replicate When a form is submitted, eForms Mobile Replicate automatically creates a table in your local SyncData database. Table Name: Derived from the Form Screen’s External ID. Columns: Derived from the Data ...