The Synchronization API is a very useful tool that makes synchronization between the Device and the Server extremely easy. You do not have to worry about how to apply changes on the server, or how to receive data changes from the server and apply them on the device.
The Synchronization API has two methods: Receive and Send, that makes that hard work automatically.
It is very important to note that the Synchronization API can be called at any time, even if the developer has set any value for the Data Receive Criteria property or Send Changes property, both methods Receive and Send are still going to work.
This document explains how to create a simple offline application calling the synchronization programs manually, using the Synchronization API to synchronize the device with the server.
Take the "Simple Version Manual" version of the Sales sample as an example. In this application's version, the application needs to be synchronized whenever the user wants to.
The first step to do that is to configure the Offline Database Object properties. As in this sample application it is necessary to manage the synchronization manually, it is needed to set the Data Receive Criteria property and the Send Changes property to "Manual" as shown in the following image:
The second step is to create a new Panel. In this example it is called “SynchPanel”, and adds 2 buttons in the layout like shown in the image below:
Finally, each button is going to have an event where the Synchronization API is called:
Event 'Receive'
Synchronization.Receive()
Endevent
Event 'Send'
Synchronization.Send()
Endevent
By doing just that, it is possible to synchronize data whenever the user wants to. When tapping the "Receive" button, the data from the server is going to be synchronized into the device, and when tapping the Send button, all local changes are submitted to the server in order to apply changes.
The Synchronization.Send method sends data to the server in a single request, that may be a problem if connectivity is very unstable and the amount of data to send is big. In that case, consider executing it when a stable connection is available or Coding your Data Synchronization programs.
Sales sample
Synchronization API
Synchronization.Receive method
Synchronization.Send method
Synchronization.ResetOfflineDatabase method
Coding your Data Synchronization programs