Dynamics

Details an integration available for Dynamics, built and maintained by Umbraco HQ.

This integration provides a form picker and rendering component for forms managed within a Microsoft Dynamics 365 Marketing instance.

Minimum version requirements

Umbraco CMS

MajorMinor/Patch

Version 8

8.4.0

Version 9

9.0.0

Version 10

10.1.0

Version 11

11.0.0

Authentication

The package uses the OAuth protocol for authentication.

Additional Configuration

To connect to your Dynamics 365 instance, the following configuration is required:

appsettings.json
"Umbraco": {
  "Integrations": {
      "Crm": {
        "Dynamics": {
          "Settings": {
            "HostUrl": "https://[INSTANCE].crm4.dynamics.com/",
            "ApiPath": "api/data/v9.2/"
          }
        }
      }
    }
  }

The above settings are for demonstration purposes. They might change depending on your personalized instance Web API.

Self Hosted OAuth Configuration

The easiest way to configure the integration is to make use of an application Umbraco has pre-configured with Microsoft. With this in place, the authorization flow will go through a proxy website Umbraco maintains before redirecting back to your Umbraco backoffice.

From version 1.2.0, we introduced an alternate approach that requires a little more setup. It removes the need for relying on any services from Umbraco when using the integration.

To use this you need to setup your own app with Microsoft and use an extended configuration like this:

appsettings.json
"Umbraco": {
  "CMS": {
    "Integrations": {
      "Crm": {
        "Dynamics": {
          "Settings": {
            ...
            "UseUmbracoAuthorization": true/false
          },
          "OAuthSettings": {
              "ClientId": "[your client id]",
              "ClientSecret": "[your client secret]",
              "RedirectUri": "https://[your website base URL]/umbraco/api/dynamicsauthorization/oauth",
              "TokenEndpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token",
              "Scopes": "https://[your instance].crm4.dynamics.com/.default"
            }
        }
      }
    }
  }
}

The authorization mode is toggled by the UseUmbracoAuthorization flag, which by default is set to true meaning that previous versions of the integration are not impacted.

The authorization specific methods are exposed by the IDynamicsAuthorizationService and implemented by two services:

The used service is provided using the AuthorizationImplementationFactory method, depending on the type of authorization selected.

If you are selecting your own authorization flow that uses the AuthorizationService, the redirect URL will be this one: /umbraco/api/dynamicsauthorization/oauth, from DynamicsAuthorizationController. Make sure to set to correct URL in the settings of the website and in the configuration for your Dynamics app.

The authorization controller uses the window.postMessage interface for cross-window communications when redirecting from the Microsoft authorization server.

Backoffice usage

To use the form picker, a new Data Type needs to be created based on the Dynamics Form Picker property editor.

The settings in Web.config/appsettings.json will be used for sending authorization and data requests to the Dynamics API, through the 0Auth Proxy for Umbraco Integrations or directly.

The Connect button prompts the user with the Microsoft authorization window, which after a successful authentication will send the authorization code back.

The retrieved access token will be saved into the database and used for future requests.

Revoke action will remove the access token from the database and the authorization process will need to be repeated.

Front-end rendering

A strongly typed model will be generated by the property value converter. An HTML helper is available to render the form on the front end.

Ensure your template has a reference to the following using statement:

@using Umbraco.Cms.Integrations.Crm.Dynamics.Helpers;

Assuming a property based on the created Data Type with the alias dynamicsForm has been created, render the form using:

@Html.RenderDynamicsForm(Model.DynamicsForm)

The selected form is embedded either through an iframe or by using scripts.

Last updated