# Data synchronization

This feature keeps track of the records that are inserted, modified, renamed or deleted in a set of selected tables, so that external applications (synchronization clients) can download only the changes made since their last synchronization.

For each change, a **Synchronization Entry** is recorded with the table, the type of change and the primary key of the record. External applications read these entries through the integration interface (**Synchronization Handler**), and confirm the range of entries they have received: the system remembers, for each client and table, the range of entries already synchronized.


1. Search for **Change Log Setup** and open the table setup (**Tables**).
2. On the line of the table you want to synchronize, select the **Synchronization Log** field.
3. If the table already contains data, choose the **Initialize Synchronization Entries** action on that line and confirm: an entry of type **Insert** is created for every existing record that does not have an entry yet. The operation may take a long time on large tables.

From that moment on, every insertion, modification and deletion in the table is recorded automatically. Clearing **Synchronization Log** stops recording for that table.


Search for **Synchronization Entries** to see the recorded changes. The page is read-only.

| Field | Description |
|---|---|
| Entry No. | Progressive number of the entry. Clients use it to know which changes they have already received. |
| Table ID | Table of the changed record. |
| Entry Type | Type of change: **Insert**, **Modify** or **Delete**. |
| Primary Key 1 … 5 | Values of the primary key fields of the changed record. |


| Action | Description |
|---|---|
| Clients | Opens the list of **Synchronization Clients**. |
| Compress | After confirmation, keeps only the most recent entry for each record, removes the entries of tables no longer selected for synchronization, and removes the **Delete** entries already received by all clients. It may take a long time. |
| Prepare Compress Task | Creates (if it does not exist yet) and opens a job queue entry that runs the compression automatically. The entry is created **On Hold**: set the schedule and enable it from the job queue entry card. |
| Check Deletions | After confirmation, checks every recorded record and, if it no longer exists in the table, changes its latest entry to **Delete**. Useful to realign entries with deletions that were not tracked. |
| Delete All | After confirmation, deletes all synchronization entries. The operation cannot be undone. |


Open the page from the **Clients** action of **Synchronization Entries**. It shows, for each external application and table, the range of entries already received and confirmed. Records can only be deleted, not created or modified: deleting a line makes the system forget what that client has already synchronized for that table.

| Field | Description |
|---|---|
| Client ID | Identifier of the external application. |
| Table ID | Synchronized table. |
| Starting No. | First entry number of the confirmed range. |
| Ending No. | Last entry number confirmed by the client. |
| Last modified | Date and time of the last update of the line. |


- Insertions, modifications and deletions in the selected tables generate an entry automatically. Renaming a record generates a **Delete** entry for the old key and an **Insert** entry for the new one.
- The **Delete** entries are removed during compression only once every client of that table has confirmed them; if no client is registered for the table, they are removed directly.