Challenges with Dynamics 365 Operations (Dynamics AX) OData Calls

While working with an Azure Logic Applications for a batch job process I ran into an issue that I could not find online support for. Through a Microsoft support case I received a swift response that I was surprised I could not find online.

The project dealt with synchronizing Dynamics 365 CRM/CE data to Dynamics 365 Operations (formerly known as Dynamics AX).  Adoxio often uses Azure Logic Apps for integration scenarios and with its array of connectors as well as the raw HTTP connector as a power tool to quickly build out integrations in a modern server less environment. 

In order to setup the integration with Dynamics 365 Operations, the HTTP connector was chosen to provide robust configuration over the built-in Dynamics 365 Operations connector.  As such it required examples of making a query on a single record in Dynamics 365 Operations, OData Feed.  In this case, this was needed in order to issue a DELETE HTTP request to the Dynamics 365 Operations site in multiple actions in the Azure Logic Applications.

The following site had some information referencing a key:
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/odata

In the documentation the example URL is [Your Organization Root URL]/data/Customers(“[key]”).  However, after viewing the format how the key is formed was not obvious, and could not find an actual example online.

 

Answer

Turns out these keys are compound in nature, Depending on the table you could require 2+ fields and values to retrieve a record.

These keys look as such:
<AX-URL>/data/CustomerPaymentJournalHeaders(dataAreaId='area',JournalBatchNumber='BAT-00002')

Another Example retrieving

<AX-URL>/data/CustomerPaymentJournalLines(dataAreaId='area',JournalBatchNumber='BAT-00002',JournalLineNumber='1')
The DataAreaId is mandatory in the key to retrieve the record. Is separates organizations in Dynamics 365 Operations. 

 

Bonus Tip

Another thing to note dealing specifically with our requirement to issue a Delete Request. In Ax deleting a record such as a Sales Order within the UI will cascade delete the Child Sales Order Lines. But if you are using the OData endpoint you must delete the child records before the parent can be deleted. Continuing with the same example you would need to delete each line item before deleting the Sales Order Header.

Once completed the Azure Logic Application provided a seamless integration of the services between Dynamics 365 CRM/CE and Dynamics 365 Operations without needing any additional servers or licenses to implement.  By using the Azure Logic Applications architecture it provided a natural extension of the to the cloud infrastructure the client was expecting and could be maintained or extended with the knowledge already gained of the standard APIs and SDKs of the Dynamics products.  Adoxio continues to use various Azure based services in their project implementations with great success for its clients.