Thursday 17 October 2013

CRM 2011 outlook synchronization process


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:
  1. 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:
    1. 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.
    2. SubscriptionClients table = Specifies which of the end user's machines is set to be the synchronizing client (based off of the IsPrimaryClient column).
    3. SubscriptionSyncInfo table = Specifies the sync metrics for each SubscriptionId (ex. StartTime, DataSize, InsertObjectCount, etc.).
    4. 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
  2. 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).
  3. 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>\AppData\Roaming\Microsoft\MSCRM\Client).
  4. 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.
  5. 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.
  6. 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.
  7. 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).

No comments:

Post a Comment