Consume Business Events from Microsoft Flow

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.

La imagen tiene un atributo ALT vacío; su nombre de archivo es image-7-1024x490.png

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…

La imagen tiene un atributo ALT vacío; su nombre de archivo es image-8-1024x450.png

We post it…

La imagen tiene un atributo ALT vacío; su nombre de archivo es image-9-1024x400.png

Et voilà! Here is the notification in our mobile phone with the invoice we have just posted.

La imagen tiene un atributo ALT vacío; su nombre de archivo es image-10-992x1024.png

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.

3 comments / Add your comment below

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Uso de cookies

Este sitio web utiliza cookies para que usted tenga la mejor experiencia de usuario. Si continúa navegando está dando su consentimiento para la aceptación de las mencionadas cookies y la aceptación de nuestra política de cookies, pinche el enlace para mayor información. ACEPTAR

Aviso de cookies