Call a logic app from a business event

Business events in D365 is a nice feature that one can latch on to and use in integrations. In this post we will explore how to call a logic app from a business event that has been triggered.


Pre-requisites:

- Azure subscription with credit
- D365FO with privileges to manage business events
- Office 365 subscription or email via Outlook.com

Business event setup, part 1, schema

In D365FO you have several standard out of the box business events called Business events catalog, located at System administration --> Setup --> Business events

  1. Locate and highlight the Business event ID, PurchaseOrderConfirmedBusiness. Press the link Download schema to download the schema file (indicated with a green circle in picture below).


  2. Open the downloaded file in notepad and keep it open to use it later


Logic app

Go to azure portal, make sure you have credit and able to create a new Logic App. I like using the Azure portal App for simple examples like this. We are to create the simplest logic app possible for our example.

  1. Create a new blank Logic app
  2. Add a new step


  3. Expand the step and copy in the entire content of your schema file into the text area Request Body JSON Schema, and save the logic app.


  4. Add another step, search up Office 365 Outlook and scroll down to Send an email (v2). You can also use Outlook.com if you do not have a Office 365 subscription. 


  5. Now you need to expand the new step and sign in with your office365 account to provide access to your email.
  6. After signed in fill in the mandatory fields, to, subject and body. In the body I have also added some parameters from the JSON schema which will fetch data provided from the business event. For testing reasons make sure your own email address is in the To field.


  7. Save the logic app
  8. Copy the URL from the first step



Business event setup, part 2, activate business event

Now we need to create an endpoint and activate the business event.

  1. Open the Business events catalog, located at System administration --> Setup --> Business events.
  2. Go to the Endpoints pane
  3. Create new Endpoint
  4. Choose type Microsoft Power Automate
  5. Give it a name and paste in your URL from step 8 (your logic app URL address) in previous section, then press OK.

  6. Now we need to activate the business event, select your business event named PurchaseOrderConfirmedBusinessEvent and press +Activate.


  7. Now a new dialog appears, choose your legal entity and the endpoint you've just created.
  8. Press OK to finish this step

You now have a basic logic app and a business event activated. To test your business event and logic app. Go and confirm a purchase order, you can monitor the run history in the logic app and see the resulting email in your email inbox. Under is an example email received from my environment.




Comments

Popular posts from this blog

Call a simple Logic app from X++

SysOperationFramework with use of Query

Retail Attributes on sales lines