Reader small image

You're reading from  Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook - Second Edition

Product typeBook
Published inMar 2020
PublisherPackt
ISBN-139781838643812
Edition2nd Edition
Right arrow
Author (1)
Simon Buxton
Simon Buxton
author image
Simon Buxton

Simon Buxton has worked with Dynamics 365 Finance and Supply Chain Management since its earliest incarnations, starting with the product in early 1999 when Dynamics 365 Finance and Supply Chain Management was known as Damgaard Axapta 1.5. Simon has been the technical lead on many highly challenging technical projects in countries all around the world. These projects included complex integrations with on-premises and external systems, ISV solutions, and many technically challenging customer solutions. Now working with Binary, he was part of a team that implemented the first Dynamics 365 Finance and Supply Chain Management implementation as part of the Community Technical Preview (CTP) program, which led to the close working relationship with Microsoft that made this book possible
Read more about Simon Buxton

Right arrow

Business Events

Business events are a relatively new feature, available as a flight in Platform 24 and generally available from Platform 26. The concept is to allow a business event to be defined that can be sent to an external target. This would stem from a requirement such as this:

"When a sales order is confirmed, send a message to the customer."

Alternatively, it could be this:

"When a Bill of materials is approved in Finance and Supply Chain Management (SCM), send a message to the production manager for secondary approval, and if approved, create a formula in the on-premise production control system."

Both of these can be done with very little coding, and most of the work is done via configuration. The framework is designed for performance, and the method by which the messages are sent is asynchronous. Even though this normally means there is a one-minute...

Technical requirements

Creating a new business event

We will create the Bill of materials is approved business event in this recipe, and also add a summary of how to create the sales order confirmed business event in the There's more... section.

For this chapter, we will create a new package. Even though a reasonable example would be to create a vehicle service order approval process using Microsoft Flow, the real-world challenge would come from hooking into standard processes such as the Bill of materials approval.

Getting ready

Before we start, we should create a new package and model named ConProductionIntegration, and then create a project with the same name. Use the recipes in Chapter 1, Starting a New Project, as guidance, and remember...

Creating an Azure Service Bus queue

A Service Bus queue is arguably the best target for a business event. This acts as a message queue, where the subscriber can read the messages in the queue. We can easily configure Microsoft Flow to read from the Service Bus.

If you have a person whose role it is to create Azure resources, they need to create a Service Bus topic and provide the following information:

  • Queue name
  • Application ID
  • Azure application secret
  • Primary connection string
  • Key Vault DNS name
  • Key Vault secret name

In order to do this, you need to be given the appropriate rights to create Azure resources and link them to a subscription. There is a small cost to this, so the subscription will need a credit in order to proceed.

For this recipe, we will be using the https://portal.azure.com site.

...

Configuring the business event to use a Service Bus queue

In this recipe, we will configure our Bill of materials approved business event to be sent to our new Service Bus queue.

The configuration of a business event is company-specific, so the events can be enabled by the company and have a different endpoint per company.

You will need the following information created in the previous recipe in order to complete this:

  • Service Bus queue name
  • Application ID
  • Azure Application secret
  • Key Vault DNS name
  • Key Vault secret name

How to do it...

To configure the business event, follow these steps:

  1. Open SCM in the browser on our Development Virtual Machine (VM), and navigate to System administration | Setup |Business events | Business...

Creating a Microsoft Flow to receive the Service Bus queue message

Microsoft Flow is a great tool for an organization to create logic flows that take data from a source, and based on a condition send a message to an onward service.

In this case, we will create a flow to read our Service Bus queue, decode the payload, and send it to a user for approval. We will extend this in the next recipe.

How to do it...

To configure Microsoft Flow, follow these steps:

  1. In a web browser, navigate to https://flow.microsoft.com.
  2. Sign in using your organizational account.
  3. Expand Data on the left, and select Connections.
  4. Click New Connection.
  5. Click the Search option, and type Service Bus. There will be one result; click the + symbol.
  6. Enter...

Receiving messages in SCM from the Service Bus

We now have a method to send a business event when a Bill of materials is approved. What would be useful is to close the loop, and use Microsoft Flow to approve the BOM that would then make the BOM active.

We don't have a way to read the bus in SCM, so we will need to write one. The main purpose of this recipe is to show how we can read the Service Bus in SCM. When writing a solution for inbound actions, we should use a similar pattern to business events, where the process is simply in reverse.

In this recipe, we will only have one adapter and a form to store the connection details. Again, this is a technical demonstration and does not deal with the security impact of storing connection strings and secrets in a table.

The main recipe stops when we can successfully read the message from the queue– this will be extended...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook - Second Edition
Published in: Mar 2020Publisher: PacktISBN-13: 9781838643812
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Simon Buxton

Simon Buxton has worked with Dynamics 365 Finance and Supply Chain Management since its earliest incarnations, starting with the product in early 1999 when Dynamics 365 Finance and Supply Chain Management was known as Damgaard Axapta 1.5. Simon has been the technical lead on many highly challenging technical projects in countries all around the world. These projects included complex integrations with on-premises and external systems, ISV solutions, and many technically challenging customer solutions. Now working with Binary, he was part of a team that implemented the first Dynamics 365 Finance and Supply Chain Management implementation as part of the Community Technical Preview (CTP) program, which led to the close working relationship with Microsoft that made this book possible
Read more about Simon Buxton