CRUD Operations using Microsoft Dynamic 365 Connector in Mule

The Microsoft Dynamics 365 Customer Relationship Management (CRM) connector for Anypoint platform enables integration with Microsoft Dynamics 365 Web API.

This connector lets you perform operations to:

This document will help you understand basic CRUD operations using Microsoft Dynamic 365 connector.

To work with this connector, first, obtain a client ID and secret for your app by logging into the Microsoft Azure Active Directory portal at portal.azure.com.

Before starting, you will need access to a Microsoft Dynamics 365 instance (online or on-premise) leveraged by Azure Active Directory; that is, Azure Active Directory is the Identity Provider that provides access to an application. Once you are done with these accesses you can start creating our Project in Anypoint.

Workflow:

First, download the Microsoft Dynamic 365 Connector from Anypoint Exchange. Use this connector in your flow with Microsoft Dynamic 365 OAuth2.0 Username and Password configuration. After that, provide the required values for connector configuration:

Dynamic 365 Connector configuration

Create:

The connector allows creating new Entity in Dynamics CRM from MuleSoft. We can use Create or Create Multiple Operation.

Image title

The payload will contain the attributes that we need to insert to create Entity. You need to pass it in object format. You can use dataweave to map the values:

Image title

To pass the value to the binded attribute, you need the syntax: “[attribute in Dynamics]@odata.bind”:“/[entityname in which current entity exist, usually appended with 's' in end for collection, you can refer to entity's logical or schema name in CRM](“[entity id]”)”

Example, in the snippet above, “Col2” is the binded value in Dynamic 365. Binded value means that it is part of another entity and is binded in this entity as well, similar to foreign key in Database. “systemuser” is the entity to which this attribute actually belongs and it is referenced in Account entity.

Overall Flow will look like below:

Image title

Image title

The payload will contain the attributes that we need to insert to create Entity. You need to pass it in object format. You can use dataweave to map the values:

Image title

Update:

We can update the existing entity using Dynamic 365 connector. We can use Update and Update Multiple operations.

Then, map the payload accordingly. You can use Dataweave to map the values:

Image title

Map the payload accordingly. You can use Dataweave to map the values:

Image title

Delete:

We can delete the existing entity using Dynamic 365 connector. We can use Delete and Delete Multiple operations.

Provide the Entity ID in payload input, eg. below in dataweave:

Image title

Provide the Entity ID list in payload input, eg. below in dataweave:

Image title

Retrieve Multiple by Query:

With this, you can retrieve data from Dynamic 365 CRM using a normal SQL query. In the connector configuration, select Operation as Retrieve multiple by the query.

Image title

You can type the query in Query Text or use the query builder to build the query for you.

It will return the result in Object format. To understand this data, you can use Object to JSON transformer.

 

 

 

 

Top