Receiving events from Dynamics 365 CRM using webhooks.

Starting with Dynamics 365 CRM 9.0 you can send data about events that occur on the Dynamics server to external applications like SCPI application using webhooks. Webhooks is a lightweight HTTP pattern for connecting Web APIs and services with a publish/subscribe model. Webhook consumers register webhook plugins about entity events. Dynamics will use these webhook plugins to make requests to consumers endpoints with information about the events.

 

The Advantco adapter supports many important features that are critical when integration with Dynamics 365 CRM online or on-premise. The Advantco adapter handles the most complex tasks so the CPI developer can focus on the mapping logics. Topics like authentication, pagination, batch operations, … are best handled by the adapter and must not assume prior knowledge of the Dynamics 365 CRM API by the SCPI developer to be able to implement common integration flows.

 

Our scenario

Receiving events from Dynamics 365 CRM using webhooks.

An event is created in Dynamics 365 CRM whenever an account is updated. We want to receive this event so the respective customer in SAP is updated with the new information from Dynamics.

 

Webhook setup

Using the Plugin Registration Tool, we register a new webhook to receive this update event for the account entity.

Receiving events from Dynamics 365 CRM using webhooks.

First, we specify the name of the endpoint url to which Dynamics will send the event in case of an update to an account. We select WebhookKey for authentication mode and specify the iflow ID. We will show you below how to get the ID for your specific iflow in SCPI.

Receiving events from Dynamics 365 CRM using webhooks.

 

We specify the entity and the attributes in the Step configuration screen. The execution mode for the event can be synchronous or asynchronous.

Receiving events from Dynamics 365 CRM using webhooks.

 

Advantco Dynamics 365 CRM Workbench

The Workbench is an important WEBUI tool to define and test the connection to Dynamics, generate schemas for different type of integration use cases and it can support testing payloads directly.

Receiving events from Dynamics 365 CRM using webhooks.

 

To be able to receive and map the account event in the iflow, we need to generate the schema for the webhook response for the account entity. Import the generated schema into your iflow as an external resource.

Receiving events from Dynamics 365 CRM using webhooks.

 

Develop the iflow in SCPI.

The simple iflow consist of one sender channel using the Advantco Dynamics 365 CRM adapter and a RFC receiver channel. The iflow ID is available by click on the General tab, you need this ID when defining the webhook.

Receiving events from Dynamics 365 CRM using webhooks.

 

Check the Enable Consuming Webhook checkbox to activate the channel to receive the account update event from Dynamics. It cannot be easier.

Receiving events from Dynamics 365 CRM using webhooks.

For completion, this is how the mapping looks like. We map the webhooks response schema to the BAPI BAPI_CUSTOMER_CHANGEFROMDATA. The schema for the webhooks response was generated using the Advantco Workbench as described above.

Receiving events from Dynamics 365 CRM using webhooks.

 

Finally, the receiver channel is a RFC channel calling the on premise SAP backend system using the predefined Cloud Connector connection.

Receiving events from Dynamics 365 CRM using webhooks.

 

Testing the use case

When we update an account in Dynamics 365 CRM, an event is triggered and sent to the webhooks endpoint url.

Receiving events from Dynamics 365 CRM using webhooks.

 

We can see that the iflow is triggered in SCPI.

Receiving events from Dynamics 365 CRM using webhooks.

 

Summary

Webhooks is an important method to receive near real-time events from Dynamics 365 CRM. The Advantco Dynamics 365 CRM adapter makes consuming webhooks events a simple exercise.

Resources:

https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/use-webhooks

https://www.advantco.com/sap-integration-adapters/sap-microsoft-dynamics-integration

 

Please reach out to our sales team at sales@advantco.com if you have any questions.