Over the past few years, several Microsoft CRM 4.0 White Papers have been produced that cover both Outlook synchronization, as well as Offline synchronization. You can find these white papers at the following locations:
The Outlook synchronization paper does a very nice job of covering the process that takes place when records are synchronized between Microsoft CRM and Outlook. After reading the paper, you may walk away with a few questions around how the synchronization tables within the MSCRM database work with the client-side .sdf files….I know that I did anyways. With the help of a few internal colleagues, I’ve put together the following information to hopefully clear up any confusion that you might have:
The CRM/Outlook synchronization process can occur in one of two ways: 1) manually clicking the “Synchronize with CRM” option, or 2) scheduled background synchronization. The actual CRM/Outlook sync process looks like this when kicked off:
- Prepare sync is called to query the server to prepare all the entities which should be synchronized down from the CRM server. There are a variety of tables used within the MSCRM database during this process:
- Subscription table = Specifies the SyncEntryTable name for each user that has been created. There is a separate SyncEntry table for the outlook sync and the offline sync for each user. A SubscriptionType of 0 = Offline and a SubscriptionType of 1 = Outlook. You’ll notice that a SubscriptionType of 2 for Address Book Provider will show as well. The ABP SyncEntry table is no longer used. The ABP sync is now handled exclusively by the Outlook MAPI sync. Each SubscriptionId is tied to a unique SyncEntryTableName.
- SubscriptionClients table = Specifies which of the end user’s machines is set to be the synchronizing client (based off of the IsPrimaryClient column).
- SubscriptionSyncInfo table = Specifies the sync metrics for each SubscriptionId (ex. StartTime, DataSize, InsertObjectCount, etc.).
- SyncEntry_<guid> = Specifies object being synchronized, the ObjectTypeCode (which tells you the entity), and the state of the sync. Remember, there is a separate Sync_Entry table for each sync process per user
- After the information is prepared on the server end, it returns xml to the client with the number of records to be synchronized for each action type (create/update/delete) for each entity type (contact, appointment, etc).
- The CRM Outlook client then makes another sdk call, GetSyncData, according to the xml returned by the prepare sync to get the crmid and change timestamp for each changed record. This information is then added to the OutlookSyncTable table in the OutlookSyncCache.sdf file. This file is located at the following location on a Win7 machine: C:users<user name>AppDataRoamingMicrosoftMSCRMClient).
- The client also tracks the Outlook item changes and adds them to the OutlookSyncTable table in the .sdf file. Now this table should contain all of the changed record information which comes from both CRM server and Outlook.
- The sync process will then process each changed record in the OutlookSyncTable table according to the change type and change timestamp. For example, if the change type from crm server is create and there is no change from the outlook client, the action will be to create an item in Outlook.
- When one record is synced successfully, the entry in the OutlookSyncTable table will be removed and the IdMappingTable table entry will be inserted/updated/deleted accordingly. The IdMappingTable table contains the mapping between crmid and Outlook entryid. When a crm record is synced down to Outlook, the table will help to find the corresponding Outlook item. The only exception to the IdMappingTable table is for appointments where we cannot find an id mapping. In that scenario, a search for an appointment with the same global object id will be done in Outlook. That is the only time that a search will be done in Outlook.
- If one entity fails and is not synchronized, then the corresponding entry in the OutlookSyncTable table will stay. The next time a synchronization takes place, this entry will be synced again unless the user chooses to ignore the error (Select the “Ignore all errors” checkbox in the sync dialog in Outlook).