Mobile - How do we handle closing the app while Sync is running?
Application Type

I have a Sync that syncs the Emloyee local storage to the server.

In the Employee local storage, I have attribute IsSyncing that I tag to True when starting the Sync, to make sure I don't have duplicate records(due to sync being called several times and having slow network) I only call the records with IsSyncing to False.

The process is:

  1. Get records with IsSyncing = False
  2. Update those records IsSyncing to True
  3. Start sync process from local storage to server (this takes sometime depends on the amount of records.

The issue is let's say the ongoing sync is on Step 3 and I close/kill the app, the IsSyncing will remain to True even though it is not synced yet to the server, in result it will basically be a bad data since I won't be able to sync it again because I'm only getting IsSyncing = False when calling the Sync process.

The reason I update the IsSyncing to True (Step 2) before the Sync process (Step 3) is because Step 3 takes some time to finish; and if two Sync is called at the same time, they will get the same records and will result to duplicate records to the server.

Any idea how do I solve this? Or maybe there is a better approach to handle this scenario? Thank you!

Hello @Kenneth1 , below is a documentation of the recommended patterns by Outsystems for Offline Sync.

You may use it as a baseline and customize it at a later end that best fits your business requirement.

Hope this helps,

Kind regards,

Hello @Kenneth1 ,

 Check out this here this is explained in Course available for Synchronization

Check Out These Forge Components Where Sync patterns are define , You can check and demonstrate

Also you can check them if it helps

Training for advanced Read/Write synchronization patterns.

Hope it helps


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.