Dynamics 365 SDK: Setting Appointment Organizer using C# + Server Side Sync


Background

A recent project called for syncing appointments created within Dynamics 365 to Exchange (and eventually Outlook) via server-side sync. One of the gotchas with this is that the appointment organizer field must be set in order for server-side sync to pick it up and push it to Microsoft Exchange. The Dynamics 365 server-side synchronization troubleshooting  guide from Microsoft explains:

Alert: Appointments can’t be synchronized because the Organizer field is not present.

Cause: The Organizer field is required for appointment records to synchronize. By default, this field isn’t included on the appointment form.

The full guide can be viewed here.

By default this field is left blank and as stated above is not displayed on the appointment form, so it can go unnoticed.

In my scenario the appointments in question are created and managed via a Dynamics 365 plugin based on a new field called “Appointment Date” on an Opportunity. The plugin fires on an update to the date or an update to the Opportunity owner and will update the appointment start / end dates and owner.

There are two ways to approach populating the Appointment organizer field:

  1. Set up a Workflow to set the organizer to the appointment owner when the owner field is updated.
  2. Set the organizer field within the plugin based on the appointment owner being updated.

Whilst the workflow approach would mean less coding, I prefer to keep the logic in one place since I already had a plugin managing the appointment and opt’ed to have it also set the organizer field.

How to set the Organizer field using the Dynamics 365 SDK (C#)

The C# code below demonstrates how to set the Organizer using the SDK. To reuse it simply update <<USER_GUID>> to a valid user ID.

As you can see the Organizer field is a little more complex when compared to the Owner field as the Owner field only requires an EntityReference.

If you have any questions, feel free to leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts