May 29, 2018

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

1013 Views
How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

Dynamics 365 for Finance & Operations (AX) has an OData interface with which we can easily integrate third-party applications with it. The generation of the proxy class makes it easier to do .net programming against this OData endpoint by creating strongly typed classes for entities and attributes which will give IntelliSense support in Microsoft Visual Studio. It helps to speed up the development process and makes the development less prone to errors.

Prerequisites:

  • Visual Studio 2017 (At the time of publishing this article, latest version of OData V4 Client Code Generator was only supported on VS 2017)
  • Microsoft Dynamics 365 for Finance & Operations (AX)

Create client-side OData proxy:

1. The first step is to create a class library project and delete the default class file.

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

2. Now go to Tools Extensions and Updates.

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

3. Click on the Online section and search for the OData V4 Client Code Generator. Now download and install the OData V4 Client Code Generator and restart the Visual Studio

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

4. Once Visual Studio is restarted, we will be able to find and add 'OData Client' item into our project.

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

5. Now open the newly added ODataClient.tt file and fill in the 'MetadataDocumentUri' section with the AX OData URL as shown in the screenshot. Once this is done, save the file and this save will trigger the creation of the Proxy file.

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

When there are new entities and attributes added to the AX system and if you want them in your proxy file, we can re-generate the proxy file easily by right clicking on the ODataClient.tt file and clicking on the 'Run Custom Tool'.

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

6. Once the generation is completed, the proxy file will get saved onto the root folder of the project. We can then build the project to generate the DLL which can be uploaded to the Azure Functions or referenced in any .Net project for the access.

How to create client-side OData proxy dll for Microsoft Dynamics 365 for Finance & Operations (AX)?

Conclusion

Please note that the entity should be explicitly exposed to the public in the AX system to be available in the proxy class.

This link ServiceSamples will give you plenty of samples to play with on how to use the proxy to authenticate and do CRUD operations against an AX system. In my next post we will see how we can use this proxy to integrate Dynamics 365 for Finance & Operations (AX) and CRM using Azure Functions.

Leave a Reply

Your email address will not be published. Required fields are marked *