A Quick Dynamics 365 Finance and Supply Chain Integration Proof Of Concept Using OData

When deciding on the best strategy for integration to Dynamics 365, OData could be a great choice if the data needs to be updated in near real-time and does not represent a large volume (which would be more suited to batch processing). In order to use OData for integrations, one will need to make sure to have data entities available and properly set to be visible by using the OData application programming interface. In this blog, we are using a console application developed in Visual Studio to integrate to Vendors in Dynamics 365. Using this simple application, one can create, read, update, and delete data from the chosen data entity.

Setup

To make your data entity available to the OData API, please set the property IsPublic = Yes on the data entity you would like to expose. Another item to double check is the list of available entities by adding “/data” on to the end of your Dynamics 365 URL like https://myd365url.dynamics.com/data. For this blog example, we are going to use the VendorsV2 data entity.

data entity vendors dynamics 365

Another necessary step towards OData integration is to log into the Azure portal and register the new application under Azure Active Directory. It is here where the necessary Authentication can be configured (such as the Active Directory Tenant ID and then the App ID and Secret). The permissions also need to be set in the Azure portal as well as to register the application in D365 at System administration>Setup>Azure Active Directory applications.

Dynamics 365 azure active directory

Once this setup is done, we move back into Visual Studio and can use some existing tools to help with authentication and the OData client. There is a helpful extension one can use called the OData Client Code Generator. Only some of the information for the specific D365 instance must be filled in and this will generate the necessary wrapper classes for the public data entities. Additionally, the client configuration with the necessary information about the particular environment and the application ID and secret values should be setup.

Now to the fun part, the console application itself. This solution will follow through simple CRUD operations (Create, Read, Update, and Delete). This script is written to create a Vendor record in a standard vanilla Contoso data environment, select and read back that record, update the Name field, and then finally delete the record. Using the Console.ReadLine() function, each CRUD operation is separated to allow seeing the results instantly in the D365 client. This demonstrates one of the biggest perks of using OData: near real-time integration capabilities.

 CRUD operation Odata

Bonus Tip: When troubleshooting issues in the console application, make sure to pay attention to the Inner Exception. This will likely give the most useful information about an error.

Using the Console Application

Running the console application, one can see it has successfully created the Vendor set up in the code snippet. Before proceeding with the rest of the application, we can instantly see the results when searching for the new Vendor in the D365 application as shown.
search vendor d365

 search vendor odata

Continuing with the application, the console reads back the newly created Vendor. This has demonstrated the ability to select and read the record. Now that the record has been selected, update it and change the Vendor Name.

update and change vendor name d365

vendor name search d365

Finishing up, the solution clears our tracks and deletes the test Vendor. This shows off the ability to perform all of the CRUD operations using OData integration and a console application.

CRUD Odata Dynamics 365

Learn more: https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/odata

Thanks for reading! You may also be interested in…

  Dynamics 365 – Defining Vendor or Customer Parent/Child Relationships