Performing Mobile Business Object Synchronization

A synchronization group is a group of related MBOs. A mobile application can have predefined synchronization groups. An implicit default synchronization group includes all the MBOs that are not in any other synchronization group.

This code synchronizes an MBO package using a specified connection:

SUP101DB.synchronize (string synchronizationGroup) 

The package database class includes two synchronization methods. You can synchronize a specified group of MBOs using the synchronization group name:

SUP101DB.synchronize("my-sync-group");

Or, you can synchronize all synchronization groups:

SUP101DB.synchronize();

There is a default synchronization group within every package. The default synchronization group includes all MBOs except those already included by other synchronization groups. To synchronize a default synchronization group call SUP101DB.beginSynchronize("default"); or SUP101DB.synchronize("default");

If there is no other synchronization group, call SUP101DB.beginSynchronize(); or SUP101DB.synchronize();

To synchronize a synchronization group asynchronously:
ObjectList syncGroups = new ObjectList();
syncGroups.add(SUP101DB.getSynchronizationGroup("my-sync-group"));
SUP101DB.beginSynchronize(syncGroups, "");
When an application uses a create, update, or delete operation in an MBO and calls the submitPending metod, an OperationReplay object is created for that change. The application must invoke either the synchronize or beginSynchronize method to upload the OperationReplay object to the server to replay the change on the backend data source. The isReplayQueueEmpty API is used to check if there are unsent operation replay objects and decide whether a synchronize call is needed.
if (!SUP101DB.isReplayQueueEmpty())
{
// There are OperationReplay not uploaded to server
ObjectList sgs = new ObjectList();
sgs.add(SUP101DB.getSynchronizationGroup("system"));
SUP101DB.beginSynchronize(sgs, "upload OperationReplay objects");
}