Microsoft Dynamics 365 Finance and Operations and Business Events as trigger for informed decision making:
Wondering how to quickly configure D365FO to get alerts based on activities/events and be able to make informed decisions?
If you have been using LogicApps, MS Flow, PowerApps and wondering when would triggers be made available with D365FO then from PU24 and onwards a private preview/hidden feature could be unveiled to enable trigger from D365FO.
There are multiple consumers which are supported across PU24 and PU25 and more to come. Some of known endpoint consumers include Service bus, Event grid, MS Flow, Azure blob storage, etc.
Sharing briefly how to leverage business events as a trigger from D365FO in MS Flow in an end to end way.
1) Enable this hidden feature (FLIGHTING) in non-production box using a SQL script as
INSERT INTO SYSFLIGHTING (FLIGHTNAME, ENABLED, FLIGHTSERVICEID)
VALUES ('BusinessEventsmaster', 1, 12719367)
2) After running the SQL statement, ensure that the following is set in the web.config file on each of the AOS
<add key="BusinessEventsMaster.FlightingServiceCatalogID" value="12719367" />
3) Reset IIS of each AOS
4) Go to D365FO-System administration - system parameters to see a new tab 'Business events - preview' and ENABLE it.
5) Before we use any of the available triggers, need to create one or many endpoints.
6) We would Microsoft Flow as our endpoint throughout this end to end demonstration for which we would need a URL from Flow to be provided in D365FO endpoint.
7) We would need to create a Flow and consume this trigger using available options.
8) Let us create a new simple Flow from scratch and use a starting point as HTTP request.
9) We need a JSON schema for flow request body using HTTP request.
10) Let us download one from the Business events screen in D365FO e.g. Purchase Order Confirmation.
11) This schema is provided in text format and we can use free tools to covert in right JSON format.
12) One such tool is https://www.jsonschema.net where we would remove the line numbers and use the schema.
13) Here is a transformed schema just in case you would like to use this example as it is
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.com/root.json",
"type": "object",
"title": "The Root Schema",
"required": [
"EventId",
"EventTime",
"LegalEntity",
"MajorVersion",
"MinorVersion",
"PurchaseJournal",
"PurchaseOrderDate",
"PurchaseOrderNumber",
"PurchaseType",
"TransactionCurrencyAmount",
"TransactionCurrencyCode",
"VendorAccount"
],
"properties": {
"EventId": {
"$id": "#/properties/EventId",
"type": "string",
"title": "The Eventid Schema",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
},
"EventTime": {
"$id": "#/properties/EventTime",
"type": "string",
"title": "The Eventtime Schema",
"default": "",
"examples": [
"/Date(-2208988800000)/"
],
"pattern": "^(.*)$"
},
"LegalEntity": {
"$id": "#/properties/LegalEntity",
"type": "string",
"title": "The Legalentity Schema",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
},
"MajorVersion": {
"$id": "#/properties/MajorVersion",
"type": "integer",
"title": "The Majorversion Schema",
"default": 0,
"examples": [
0
]
},
"MinorVersion": {
"$id": "#/properties/MinorVersion",
"type": "integer",
"title": "The Minorversion Schema",
"default": 0,
"examples": [
0
]
},
"PurchaseJournal": {
"$id": "#/properties/PurchaseJournal",
"type": "string",
"title": "The Purchasejournal Schema",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
},
"PurchaseOrderDate": {
"$id": "#/properties/PurchaseOrderDate",
"type": "string",
"title": "The Purchaseorderdate Schema",
"default": "",
"examples": [
"/Date(-2208988800000)/"
],
"pattern": "^(.*)$"
},
"PurchaseOrderNumber": {
"$id": "#/properties/PurchaseOrderNumber",
"type": "string",
"title": "The Purchaseordernumber Schema",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
},
"PurchaseType": {
"$id": "#/properties/PurchaseType",
"type": "string",
"title": "The Purchasetype Schema",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
},
"TransactionCurrencyAmount": {
"$id": "#/properties/TransactionCurrencyAmount",
"type": "integer",
"title": "The Transactioncurrencyamount Schema",
"default": 0,
"examples": [
0
]
},
"TransactionCurrencyCode": {
"$id": "#/properties/TransactionCurrencyCode",
"type": "string",
"title": "The Transactioncurrencycode Schema",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
},
"VendorAccount": {
"$id": "#/properties/VendorAccount",
"type": "string",
"title": "The Vendoraccount Schema",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
}
}
}
14) In Microsoft Flow, we would use the schema and create our Flow starting point using 'HTTP request' and with method 'POST'.
15) We can choose single path or parallel path for notifying an user. Leveraging an email notification to be sent as soon as a Purchase Order in D365FO is confirmed. This could be a mobile notification or any other out of box available Flow outputs.
16) We can choose from the list of fields mentioned in D365FO and in the JSON schema to use in notification.
17) Save the Flow and copy the URL to D365FO business events endpoints screen.
18) Next activate the specific business event for 'Purchase Order Confirmation' from catalog.
19) Last initiate batch job for business events to keep polling for such activities in D365FO.
20) Confirm a PO and notice the results in your email via notification.
21) You can also see the flow execution history.
Hope this end to end series of leveraging events from D365FO and consuming it actively in other places for decision making is awesome. Looking forward for more feature addition in this area.
*This post is locked for comments