With the release of PU24 we finally can use Business Events! It’s not enabled out of the box, but with a bit of configuration you can have it up and running in no time. Lets take a look!

Prerequisites

  • Business events are available in Platform update 24 and later

How to enable Business Events for non-production environments

For Production environments you have to log a support case with Microsoft

1. Log on to your VM, open up SQL Management Studio and run the following SQL-statement:

INSERT INTO SYSFLIGHTING (FLIGHTNAME, ENABLED, FLIGHTSERVICEID) VALUES (‘BusinessEventsMaster’, 1, 12719367)

2019-03-19_1229

2. Verify that this line has beed updated with the following information in the web.config file:

2019-03-19_1241

3. Perform iisreset

2019-03-19_1241_001

4. Go back to the D365FO client and open up the Business Events form (System Administration -> System Parameters -> Business Events – Preview)

5. Click “Yes” to enable Business events

2019-03-19_1317

Using Business Events with Microsoft Flow

So let’s set up a scenario where we can actually use the Business events. Inside the Business Events catalog there are multiple events defined by Microsoft that are ready to be used. I started out using the SalesInvoicePostedBusinessEvents which is triggered when a user posts a sales order invoice. Using business events and Microsoft Flow I want get a notification on my phone and an email when a user posts an invoice. The setup is fairly easy. I’ll show you how.

1.First we will start by downloading the schema for the event.

2019-03-19_1322

Then head over to https://www.jsonschema.net/ and copy/paste the JSON from the file into the left column (This will make Microsoft Flow able use each data element separately). Click the Infer Schema button and click the middle button in the right side of the page to remove line numbers and copy the script:

dsadsadsa

2. Now we will create our Flow. D365FO will send information to our Flow so we will need a “When a HTTP request is received” trigger (This is an incoming API call that could use actions in a Logic App or other API to trigger this flow) to actually start the Flow. Log on to Microsoft Flow and create a new Flow from blank and add the trigger. Insert the copied JSON schema and set the method to “Post”:

2019-03-19_1502

3. As I want to be informed on my phone and via email I need to create a Parallel branch so that I will be notified simultaneously. Here I can add some Dynamic content like InvoiceId, InvoiceAccount and Sales Order Id. Basically any of the information that I get from the Business Event:

2019-03-19_1508

4. My finalized Flow looks like this:

2019-03-19_1448

5. Hit Save and copy the HTTP POST URL:

2019-03-19_1511

6. Then go back to D365FO and configure a new endpoint:

2019-03-19_1332

7. Select Microsoft Flow, insert your URL and hit OK:

2019-03-19_1333

8. Activate the Business Event, chose the legal entity and select your newly created endpoint:

2019-03-19_1334_001

9. Go ahead and post an invoice from a sales order. Then go back to the System Parameters and start the Business Event Batch job:

2019-03-19_1516

10. After a little while I get a notification in the Flow app and an email telling me that the invoice has been posted:

file-1

11. Also, I can go back to my Flow and see that it ran successfully:

2019-03-19_1518

Summary

Business Events can be used in so many different scenarios and I personally think this is one of the coolest new features for D365FO! There’s a lot of new features in PU24 and Application update 10, to much to even go through, but I just want to include a screenshot of the new user interface for Finance and Operations which is now more streamlined with the other Microsoft applications (Good job Microsoft :)):

2019-03-19_1435

 

As always, feel free to use the comment section below or send me an email!

Also, a big thanks to this blog for showing me the handy feature of the JSON Schema Tool!