# Microsoft Dynamics 365

{% hint style="success" %}
**Available for:** Preference Management Platform (PMP)

**Premium Feature:** Microsoft Dynamic 365
{% endhint %}

Didomi allows you to update your Microsoft Dynamics contact attributes with the preferences collected through your preference management platform (PMP).

{% hint style="info" %}
Alternatively, the Microsoft Dynamics 365 integration can be performed directly from the Didomi console for the Preference Management Platform (PMP).
{% endhint %}

## Implementation

### **Connection**

Didomi connects to Microsoft Dynamics Dataverse on your behalf through the following parameters:

* Client ID
* Client secret
* Server instance
* Azure tenant ID

### **Options**

**Upsert mode**

You can choose allowing Didomi to create contact in Microsoft Dynamics 365, by setting `upsert_mode` to true. Otherwise, when a consent is collected but the `organization_user_id` value does not match with any contact in Microsoft Dynamics 365, the consent update will not be propagated.

**Bidirectional flow**

* Didomi also supports a bidirectional flow by creating a webhook in Microsoft Dynamics on your behalf. The goal of the webhook is to react to your contact changes and then update your Didomi users accordingly.
* Didomi identifies your Microsoft Dynamics contacts using the `organization_user_id` property.
* Before setting the bidirectional flow, please make sure the application user created for your integration in Microsoft's Power Platform admin center have the following permission assigned: `System Administrator`.
* Once the integration is fully configured, please deallocate the permission `System Administrator` perviously assigned.

### **Mapping**

Didomi uses the entity contact of Microsoft's Dataverse and sends the contact attribute property when updating a contact. Hence consent events are mapped to Microsoft Dataverse's contact attributes.

## Configuration

| Property        | Description                                                                               | Required                  |
| --------------- | ----------------------------------------------------------------------------------------- | ------------------------- |
| Client ID       | A client ID of the created Azure Enterprise application                                   | Yes                       |
| Client secret   | A client ID of the created Azure Enterprise application                                   | Yes                       |
| Azure tenant ID | Tenant ID of your Azure app settings                                                      | Yes                       |
| Server Instance | Your REST API endpoint                                                                    | Yes                       |
| Upsert mode     | By setting upsert\_mode to true you allow Didomi to create contacts in Microsoft Dynamics | No, Default value = false |
| Mappings        | Mapping for properties between Didomi and Microsoft Dynamics Dataverse                    | Yes                       |

### Example

```javascript
{
    "type_id": "microsoft-dynamics",
    "authentication": {
        "client_id": "your_client_id",
        "client_secret": "your_client_secret",
        "tenant_id": "your_azure_app_tenant_ID",
	"instance": "your_rest_api_endpoint"
    },
    "properties": {},
    "mappings": [
        {
	    "id": "dataverse_contact_attribute_logical_name",
	    "value": "consents_purposes_newsletter_enabled"
	}
    ],
    "upsert_mode": true
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/integrations/third-party-apps/microsoft-dynamics-365.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
