Dynamics CRM, Server-Side-Synchronization

Automatically set the userdecision on mailbox sync errors

If you connect your exchange mailbox with crm, you might already have appointments in your mailbox. Also, there might be some appointments in CRM.

If you have an appointment in exchange and CRM at the same time, CRM will show you an alert, asking you if you want to import this.

In my case, I always want to import the appointments from Outlook to CRM and I want this automated.

After some searching, I found a solution, based on the blog of a crm developer.

If there is an alert in CRM, where the user has to decide, if the item should be synced, there is an entry in the CRM-database called userdecision in the table exchangesyncidmapping. This attribute cannot be retrieved via the API of CRM, but it can be modified via a plugin.

 

Therefore, create a plugin that listens on the “Create”-Message of the entity exchangesyncidmapping

exchangesyncidmapping plugin
Plugin with “create”-message on exchangesyncidmapping

And on the “Create”-Message of the Tracelog.

tracelog plugin
Plugin with “create”-message on traclog

Why on both entities?

The plugin in the exchangesyncidmapping will set the userdecision. This means, that the predefined flag is set on the first synchronization. On the next synchronization, the decision will be interpreted and the item will be synchronized.

If you want to set the status not only for appointments, but also for contacts and tasks, you have to select based on the lastsyncerrorcode:

  • 101: appointments
  • 102: contacts
  • 103: tasks

The Plugin on the tracelog is needed, that the alert will be deleted, after the item is synced. Because this alert will be automatically created, we have to set the flag canbedeleted, that it will be deleted, after the sync.