Skip to main content

Notifications

Announcements

Dynamics 365 for Finance and Operations Integrations using Logic Apps and Business Events

Despite Power Automate (formerly called Flow) being handy to deploy integrations, the platform has limitations this is the reason a lot of the D365FO integrations are using Logic Apps. Logic Apps can enable advanced integrations scenarios like B2B processes where enterprise-level Azure DevOps and security practices are required.

Logic Apps  is a cloud service that helps you schedule, automate, and orchestrate tasks, business processes, and workflows when you need to integrate apps, data, systems, and services across enterprises or organizations

Every Logic App workflow starts with a trigger, which fires when a specific event happens, or when newly available data meets specific criteria. Many triggers provided by the connectors in Logic Apps include basic scheduling capabilities so that you can set up how regularly your workloads run. For the Dynamics 365 for Fin & Ops Connector, the triggers are the Business Events. On D365FO a Business event lets external systems receive notifications using small payload messages. Since these events happen in the context of business processes, they are called business events that enable business process integration.

 The business event can be used by:

  • Azure Service Bus
  • Azure Logic Apps
  • Microsoft Automate
  • Azure Functions
  • HTTPS Trigger

I will show you step by step on how to create a Logic App using a D365FO  Business event as a Trigger. At a high level in this example, every time that a new Free text invoice is posted it will trigger Logic App to send a notification email:

pastedimage1588172663969v1.png

Create a new Logic Apps

1. Sign in to Azure portal

https://portal.azure.com

2.Select Create a resource > Logic Apps > Create

pastedimage1588172714673v2.png

pastedimage1588172723783v3.png

 3.Select a Resource Group, write down a Logic App Name and click on Review+Create

 pastedimage1588172810551v4.png

 4. On the Logic App page select the Logic app designer option and then select Blank Logic App

pastedimage1588172848806v5.png

5. Search for Dynamics 365 for Finance and Operations and select the connector.

pastedimage1588172883557v6.png

6. You will notice a trigger named When a Business Event occurs. Select this trigger.

pastedimage1588172901411v7.png

7. Sign in to create a connection to Dynamics 365 for Fin & Ops.

pastedimage1588172987314v8.png

8. Select your environment instance, category, event name, and click to Add a new parameter to add a legal entity.
pastedimage1588173005362v9.png

pastedimage1588173030524v10.png

9. Select the New Step button to add a new action

10. Search for the Parse JSON data operation. This step is needed to parse the message with the schema of the data contract.

pastedimage1588173113539v13.png

11. Select the content field of Parse Jsonaction, then the Body output from the previous step should appear as an option. Select Body.

 pastedimage1588173131093v14.png

12. Enter the schema of the contract. They schema is found in Dynamics 365 for Finance and Operations. Go to System Administration - > Business Events -> Business Events Catalog. Because the app provides only a sample payload you can use the Logic App capability to generate a schema from a payload. Select Free text invoice posted and select the Download schema This will download a text file. Open the text file and copy the content.

 pastedimage1588173154788v15.png

pastedimage1588173168368v16.png

pastedimage1588173176966v17.png

13. Go Back to Logic App page on the Azure Portal and select the Use sample payload to generate schema Paste your text file content and select Done.

pastedimage1588173196798v18.png

pastedimage1588173206038v19.png

Depending on the quality of your sample payload, your generator will not be able to distinguish between an integer and a real number. This is true if the real number is provided as a whole number in the sample payload. Review your generated schema and check if you need to change an “integer” into “number” on the InvoiceAmountInAccountingCurrency and InvoiceTaxAmount parameters. In JSON, a “number” data type means real number.

pastedimage1588173230793v20.png

14. Choose another final action to consume the business event content. For instance, you can send an email (or post a text message to Teams) to notify the customer about payment details. Search for email and select Office 365 Outlook

pastedimage1588173258859v21.png

15. Select Send an email (V2) and change the TO and create a subject and Email body based on the schema of the parsed json.

pastedimage1588173291004v22.png

pastedimage1588173298994v23.png

16. Save the logic App.

pastedimage1588173315663v24.png

Trigger a Business Event

After you save your Logic App, it creates an endpoint, then it activates the business event for you. There is no remaining configuration step apart from verifying that the endpoint has been correctly configured before triggering an event.

  1. From Dynamics 365 for Finance and Operations navigate to System Administration > Setup > Business Events.
  2. Select Endpoints.
  3. Verify that a new endpoint has been created with a GUID appended in the name.
    pastedimage1588173346011v25.png
  4. If you check the Active eventstab you can also verify that “Free text invoice posted” is activated for legal entity USMF.
    pastedimage1588173375557v26.png
  5. The final step is to trigger the business event of a posted customer payment and check whether the flow runs, and you receive an email with customer payment details.
    Go to Accounts Receivable > Invoices > All Free text invoices.
    In this example, I will select invoice US-001 and click Post
    pastedimage1588173414121v27.png
  6. Click Ok on the posting screen.
    pastedimage1588173435559v28.png
  7. Review if the Logic App runs automatically on the Logic app page of the Azure Portal
    pastedimage1588173453638v29.png
  8. In this case, we can see that the Logic App ran successfully

    pastedimage1588173522578v30.png
  9. Check your email for the message.
    pastedimage1588173544994v31.png

Comments

*This post is locked for comments