In this article we will cover the topic how any Create / Update / Delete record event can be emitted in D365 SCM and 3rd party applications can capture the event and payload and take corresponding action. This applies to D365 SCM, D365 Commerce as well as D365 Finance previously known as D365 F&O (Finance & Operations) going forward in this article we will refer to all above applications collectively as D365 SCM as it applies to all above application versions.
D365 SCM offer many options to integrate / connect and exchange data with 3rd party applications. Previously D365 SCM offer Business Events a framework where certain events such as sales order invoice, workflow actions and many others can be captured near Realtime via batch job. Out of box a catalog is available for business events however in many use cases developers must extend using business events framework to start generating required events. Microsoft recently extends Business events concept on all OData based data entities using Data Events.
Data events are events that are based on changes to data in Finance and Operations apps. Create, update, and delete (CUD) events can be enabled for each entity. For example, if the Create event is enabled for the Purchase order headers V2 entity, an event notification is emitted every time that a new purchase order is created in the database.
All standard and custom entities in Finance and Operations apps that are enabled for Open Data Protocol (OData) can emit data events. In the data event catalog, each event for an entity is listed as a data event that subscriptions can be established for. The concept of activating the data event and associating it with an endpoint resembles the concept of business events. When a data event occurs, the payload of the event contains the corresponding entity record.
Pre-requisites
This article assumes you already have a D365 F&O trial license and tier-1 development sandbox available.
- Acquire D365 F&O Trial License: If you are new to ISV development with D365 F&O or learning D365 F&O development. You can sign up for trial license to kick off your development journey with D365 F&O. Once you signed up for trial account you can spin off a cloud VM to host your D365 F&O sandbox following the article here. Kindly note the environment (VM) hosted on Azure will be charged to partner’s azure subscription use auto shutdown scripts to control consumption based on need.
- Enable the Microsoft Power Platform integration to enable the data exchange between D365 SCM and power platform on Dataverse.
- Have familiarity with OData data exchange concepts and familiar with nomenclature of API URIs and supported operations. The following article can serve for quick refresher on OData Capabilities of D365 Finance & Operations APIs.
Data Events Basic Components:
Let’s start with some key concepts of Data Events which are important in architecting the whole mechanism from emitting the event, route to specific endpoint and route to subscriber 3rd party application.
Data Event Catalog: In System Administration -> Business events catalog form there is a tab for Data Events Catalog. We will find the list of all OData entities in that environment. To start generating the events which emit almost Realtime please refer to performance benchmark for event burst capacity and limitations. All OData here has Create / Update and Delete events lists. To activate any specific data event for all legal entities or specific legal entity can be initiated by pressing Activate button. When activating the event, a virtual entity get provisioned in Dataverse and all data get synchronized from D365 SCM to Dataverse. Data event catalog can share the list of fields which are being shared as payload whenever an event is triggered.
Endpoints: The destination to which these data events can emitted by platform as follows.
- Azure Service Bus Queue
- Azure Service Bus Topic
- Azure Event Grid
- Azure Event Hub
- HTTPS
- Azure Blob Storage
To create authorized endpoints where data events can be emitted can be done in System Administration -> Business events catalog from there is a tab Endpoints where settings of active endpoints can be configured along with their URLs / Credentials settings. Most of the endpoints rely on Azure Key Vaults for storing sensitive credentials / URLs. For more details on endpoints please refer to manage business event endpoints.
Setup Data Event in Action:
Let’s start with setup to emit data event. In the example below we will setup data event on SalesOrderHeader data entity on creation, we will setup an endpoint on Azure Event Grid as Azure Event Grid Topic and setup one Azure Storage Queue as destination for the data event. In case of actual use case the subscriber could take a message from queue or setup its own endpoint for message delivery.
Setup Endpoint:
Please follow Procedure 1,2 and 3 from Business events and Azure Event Grid to 1) create Azure Event Grid Topic, 2) Key Vault Secret and 3) Register a new application.
You will have all the information needed to set up an endpoint for capturing data events. Press OK, system will validate the information and a new endpoint will be established to be used for data events.
Activate Data Event:
Now once we have the endpoint available, we will select the desired entity in our case SalesOrderHeader entity with Create operation and once we press Activate, system will take some time and provide us the screen to select the legal entity and endpoint for which this data event to be activated.
Once we press ok, system will setup required trigger, Dataverse settings for data sync and all plumbing work to trigger the event and send to configured endpoint. We can see this in the Active data events tab.
Create Event Subscription:
To create event grid topic subscription please follow the following steps. Please open your Event Grid Topic in the azure portal. From Overview select Event Subscription
Select the appropriate EndpointType as well Storage account and queue name where these messages will be stored once received.
Test the data event:
Once all setup is done now if any integration is triggered via SalesOrderHeader or from D365 SCM someone create a new sales order in USRT legal entity it will emit the data event to the azure event grid topic and subsequently the message will land in storage queue.
We created one sales order in the system recently and we will check it in message queue.
We can view message in Azure Storage Explorer.
We can view the contents of message as follows by clicking View Message.
Conclusion:
In this post we have seen concept of Data events and how we can emit Create / Update or Delete OData entity record event from D365 SCM to Azure Event Grid Topic. The same concept can be leveraged for any other data event catalog event for any other needed endpoint.
References:
*This post is locked for comments