Offline sync with concurrent users

Hi All,

I have a prototype application with sub forms and have 6 users. I am testing the scenario of intermittent / offline data sync scenario. I have a field called product # which is key value having initial value set to MAX(Data Capture[Product # / # de produit])+1 logic.

For testing I opened 2 browsers and turned off the wifi. Added a new record using both the browsers. In this case, both have the product # as 1. I save the records and turn wifi back on, I notice only the one of the record is saved in the back-end. But application show their respective data on the front end. That means, browser 1 showed the data added by browser 1 itself and same for browser 2. Backend had data for only browser 2.

Ideally, i would like all the data being added for both the user and is also visible for everyone. Any suggestions how to achieve this?

Hope to find an answer for this :slight_smile:

Hello @rishi29, the use case you’re describing is completely incompatible with secuential key values, you can read more here:

If you switch your product number key expression to a uniqueid() you would have no issues, but as you have noticed, when offline several users can try to add a record with the same key, which can lead to some of the inconsistent behavior you encountered.

3 Likes

Hi Rafael,

Thank you for the updates. I changed the Product number to uniqueId() and it works. However, I am using a scenario of nested forms. So there are two tables called Data Capture and Level Management. Data Capture has a Product number which is part of Level management product number and is set to type ref.

The uniqueID() works perfectly fine for level management table which is the parent table. But when syncing data from offline user for the child form, same behaviour is observed as my previous comment. Any advise?

To be clear, only one of the record is added into Data capture application but front end shows both.