In this blog, I will illustrate how you can integrate Microsoft Dynamics AX 7 with other applications using OData services.
There are few different options that Dynamics AX 7 offers in terms of integration.
|Service endpoint||AX 2012||Dynamics AX 7|
|Document Services (AXDs)||Yes||No – Replaced by data entities|
|SOAP-based Metadata Service||Yes||No – Replaced by REST metadata|
|SOAP-based Query Service||Yes||No – Replaced by OData|
|OData Query Service||Yes||No – Replaced by OData|
|SOAP-based Custom Service||Yes||Yes|
|JSON-based Custom Service||No||Yes (New)|
|OData Service||No||Yes (New)|
|REST Metadata Service||No||Yes (New)|
Today we are going to look at the newly introduced Data entities. Data entities replaced ever so famous Document Services from Dynamics AX 2012.
What is a data entity?
Data entity provides conceptual abstraction and encapsulation (de-normalized view) of underlying table schemas to represent key data concepts and functionalities.
In simple terms, it replaces all those complex and fragmented concepts of AXD, Data Import/Export Framework (DIXF) entities, and aggregate queries with a single concept. So, you will have a single stack to capture business logic and to enable scenarios such as import/export, integration, and programmability.
In Dynamics AX 7 data entities can be exposed by setting the IsPublic property in the Application Object Tree (AOT).
Data entities support complete CRUD (create, retrieve, update, and delete) functionality that users can use to insert and retrieve data from the system.
Consuming a standard Data Entity using OData
Let’s assume we want to get a list of all open purchase orders from AX. For this purpose, there is an existing data entity in Dynamics AX 7 that we can use. This entity is named as PurchPurchaseOrderHeaderEntity. You can find it at the following navigation:
AOT -> Data Model -> Data Entities -> PurchPurchaseOrderHeaderEntity
Let’s make sure it is set to Public. So, we can consume it. Open PurchPurchaseOrderHeaderEntity and open the properties of this data entity.
We are interested in two properties here. Firstly, IsPublic property should be Yes. Also, note down the Public Collection Name of Data entity. We will use this name to get our list of Open Purchase orders.
Now open your browser and log into AX and copy the base URL of AX.
In the following URL replace [baseURL] by your AX’s URL:
https://[baseURI]/data/PurchaseOrderHeaders?$filter=PurchaseOrderStatus eq Microsoft.Dynamics.DataEntities.PurchStatus’Backorder’ and dataAreaId eq ‘usmf’&cross-company=true
Here, we are applying query filter to get only open purchase orders from USMF legal entity:
- PurchaseOrderStatus eq Microsoft.Dynamics.DataEntities.PurchStatus’Backorder’ will make AX return only purchase orders with PurchStatus equal to Backorder(Open order).
- dataAreaId eq ‘usmf’ will make AX return data from USMF Legal entity.
Please note you have to add cross-company switch if you want to get data from Legal entity other than defaulted on your user.
You will get a list of Open purchase orders as a result of the above-mentioned query.
OData Services, JSON-based Custom Service, and REST Metadata Service support standard OAuth 2.0 authentication. For this, you need to create a native client application or Web application (Confidential client).
Once you have setup your application and authorized your user you can consume this service from your application.