Update: Since Microsoft Ignite announcement, Microsoft Flow is called Microsoft Power Automate.
In the previous post, we talked about Business Events in Microsoft Dynamics 365 for Finance and Operations, or it would be better to say in Microsoft Dynamics 365 Finance and in Microsoft Dynamics 365 Supply Chain Management (I think… 🤔). We were talking about what business events are, what type of business events are available and about the different endpoins that we can use to consume them among other things.
Today, we are going to see, in a practical way, the steps we have to follow to use these business events and to consume them from external aplications. In this specific case, we are going to see how to consume the event CustFreeTextInvoicePostedBusinessEvent from Microsoft Power Automate. This event, as you can imagine, will be triggered each time a user posts a free text invoice.
The first step is to create the flow. We create an empty flow and we select the trigger When a Business Event occurs, then we fill the needed fields by selecting the Dynamics 365 instance we want to use, the category, the business event and the legal entity.
Now, we proceed to save the flow. Once the flow is saved, we can check that a new Microsoft flow endpoint has been created inside of #MSDyn365FO (#MSDyn365F, #MSDyn365SCM) automatically for the legal entity selected in the flow. Months ago, the steps to activate the business event and create the endpoint had to be done manually, currently, as we have an specific connector, they are automatically done.
Now we continue editing the flow. We add a new step Parse JSON. In this step we will receive the business event content. To set it up, we add in the field Content the Body of the event, and in the Schema field we copy the schema of the business event that we are using. To get this schema, we need to go to the Business events catalog, select the business event and click to the Download schema button.
By clicking in this button, we will download a .txt file that contains an example of the content we are going to receive, and we just have to copy and paste this text in the flow item, through the option Use sample payload to generate schema.
To finish the process, we can continue with the concrete action we want to perform through the flow. For this example, we are going to send a notification to the mobile phone each time a free text invoice is posted, so we need to add a step Send me a mobile notification.
As you can see in the previous image, we can use all the fields that we find in the business events catalog because the Parse JSON step give us all this information in separated variables so we can work with them.
Finally, we just need to save the flow, post an invoice and check that everything works fine, so here we go:
We create the free text invoice…
We post it…
Et voilà! Here is the notification in our mobile phone with the invoice we have just posted.
As you have seen, we have an extemely powerful and useful feature, and we can use it and take advantage of its benefits just by making a small configuration.
Although the business events catalog is quite broad, does not cover all the needs we may have, so, in the next post, we will discover how to develop our own business events. In this way, we will be able of issuing notifications when some actions that are not covered by the catalog occur thanks to our custom business events.