Issue with object Synchronization

Hi All,   We are facing an issue while synchronization of object from mobile device. Error message below:   Failed to synchronize object '*****************': com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreRuntimeException: Exception occurred in action '{<object details>,"type":"ChangeAction"}', all database changes executed by this action were rolled back. To prevent data loss, the changes have been stored under 'System.SynchronizationError' with id '6192449487967453'.   Suprisingly sync for the same object works when it is not changed from Portal. This occurs only when we change an object from the Web Portal and change the object again from Native mobile app and try to sync.   Any pointers highly appreciated. (Already explored Auto-Commit but there are none).   Regards, Sharad R K
1 answers

Hi Sharad,


See this documentation.


What you experiencing is a potential data conflict which Mendix notices and handles by creating the SynchronizationError object. To get a little more insight, I would propose to make a data grid with all SynchronizationError including the createdDate, so you can monitor when these errors have occurred. 


Now for the solution, there are multiple approaches on how to solve this, I will discuss two:

  1.  Make sure data cannot be changed server side as long as someone on native can edit the data. This way a data change on both native and on the server can never happen, thus never resulting in SynchronizationErrors.
  2. Create a shadow model on native, and don't change the object that can potentially be changed on the server, but change the shadow object (you could name your native model for example Native<EntityName>,) which you are manually going to sync to the server by checking every attribute and saving the value if it has been updated. You still have to decide on logic here to who wins: the first one who made the change or the last one. Or you can make a data conflict screen to manually resolve these kind of conflicts.