Fender IT Logo

Integrating Business Central Sales Orders with Power Automate

A Developers Guide

Published Sun Feb 02 2025
Integrating Business Central Sales Orders with Power Automateby Tye Fender
Integrating Business Central Sales Orders with Power Automate

In today’s fast‑paced digital landscape, seamless communication between ERP systems and collaboration tools is key to operational efficiency. In this post, I share two practical methods for integrating Microsoft Dynamics 365 Business Central with Power Automate to automatically create Microsoft Teams chats when a sales order is released. Whether you’re a Business Central consultant, IT developer, or simply looking to streamline your processes, this guide will help you implement a robust solution while demonstrating real‑world expertise.

Introduction

Microsoft Dynamics 365 Business Central is a powerful ERP system, and when paired with Microsoft Power Automate and Teams, it opens up a world of process automation possibilities. In this post, I’ll walk you through two methods for automatically creating Teams chats when a Business Central sales order is released:

Method 1

A simple approach using hardcoded Teams user IDs.

Method 2

A dynamic solution that reads a Teams tag and filters out duplicate or unwanted IDs (like the flow creator’s).

These examples are designed to not only showcase the integration but also to empower you to customize and scale your own solutions.

The Business Case for Integration

Integrating Business Central with collaboration platforms like Teams can:

Improve Communication

Automatically notify the right team members when a sales order is released.

Enhance Productivity

Reduce manual intervention and ensure that the appropriate stakeholders are engaged immediately.

Boost Customer Service

Enable faster decision‑making and problem resolution by keeping everyone in the loop.

By automating these processes, businesses can achieve higher efficiency, reduce delays, and improve overall customer satisfaction.

Method 1: Hardcoded Teams Chat Members

Overview

The simplest way to create a Teams chat is to use Power Automate with hardcoded user IDs. This method is ideal when the list of recipients is fixed and rarely changes. For example, if you always want the same set of sales managers to be notified, hardcoding might be sufficient.

Embedded entry image

Implementation Highlights

Trigger

When a Business Central Sales Order record is created and released.

Action

Use Power Automate’s “Create a Chat” action and manually enter the Teams user IDs (separated by semicolons).

Initialize a Boolean Variable

Name: isReleased

Type: Boolean

Value: false

Create a Chat

Add your team members directly using their email address, separated by a semicolon.

Members to add: tye@fenderit.com.au; kyle@fenderit.com.au

Do Until

  • Check and delay until the Sales Order status is set to "Released".

  • See the bottom of the post for details of the Do Until block.

Pros

  • Straightforward setup.

  • Minimal configuration.

Cons

  • Not scalable if teams change frequently.

  • Hardcoding values means manual updates inside of Power Automate are required if user roles change.

Method 2: Dynamically Adding Teams Chat Members via Tag

Overview

For a more robust solution, the dynamic method leverages Teams tags. Here, Power Automate retrieves a list of team members associated with a specific tag, filters out the flow creator (to prevent duplicate member errors), and then constructs a semicolon‑separated string of user IDs.

Embedded entry image

Implementation Highlights

Trigger

  • When a Business Central Sales Order record is created and released.

Dynamic Membership

  • List members of a tag

  • Retrieves an array of team member objects.

Pros

  • Fully dynamic

  • Automatically adapts to team changes

Cons

  • Slightly more complex configuration

  • Requires careful handling of JSON data and string manipulation

Key Code Snippet: Extracting and Joining User IDs

Below is an example of how to use an Apply to each loop in Power Automate to extract and join user IDs:

1. Initialize a String Variable:

Name: UserIdsString

Type: String

Value: (Empty)

2. Filter Array

  • Excludes the current user (or any undesired IDs).

From: body/value (of List the members of a tag)

Filter Query: @not(notequals(@{item()?['userId']},@{outputs('Get_my_profile_(V2)')?['body/id']}))

3. Select & Join

  • Extracts the user IDs and combines them into a properly formatted string.

  • From: Body of the Filter Array

From: Body (of Filter Array)

Map: userID: userID

  • Note: the second userID value is dynamic, from the Filter Array output

4. Apply to Each Loop

From: The output of the Select action

Map: userID: userID

Inside the Loop: Append to string variable:

Name: UserIdsString

Value: concat(item()['UserId'], ';')

5. Remove Trailing Semicolon: Use a Compose action with:

Inputs: substring(variables('UserIdsString'), 0, sub(length(variables('UserIdsString')), 1))

6. This results in a string formatted like:

f95d9a0c-9f5f-41b1-8d95-a3c8f5edb1ce;e0a4f123-6cdb-41d3-b0a9-c83b9e1d76a4;a4f7b59a-dab2-4fbd-a1e6-938cc9bfa63e

Step‑by‑Step Implementation

1. Set Up the Trigger in Business Central

  • Trigger: Configure the flow to start when a sales order record is created (v3) and then check for its “released” status using a Do‑Until loop.

2. Retrieve Teams Tag Members

  • Use the List members of a tag action to get all members associated with the desired Teams tag.

3. Filter Out Unwanted Members

  • Use Filter Array to exclude the current user (obtained dynamically via Office 365 Users – Get my profile (V2)).

4. Extract and Join the User IDs

  • Use a Select action to map each member to a plain object with a key (e.g, UserID).

  • Then, use an Apply to each loop to append each user ID to a string variable.

  • Finally, remove the trailing semicolon to prepare the final string.

5. Create the Teams Chat

  • Pass the final user IDs string into the Create a Chat action.

Inside the Do Until Block

Condition

Both flows have a Do Until block that checks if the string IsReleased is equal to true. IsReleased is set by Condition 1, when the "Status" of the Business Central Sales Order record is set to "Open".

NOTE: Power Automate refers to "Released" in Business Central as "Open" 😛

Set Variable

Both instances of Set Variable will set isReleased to true.

Do Until

Keep running until isReleased is true.

Embedded entry image

Conclusion

Integrating Business Central with Power Automate and Teams can significantly enhance your operational workflows—whether you opt for the simplicity of hardcoded user IDs or the flexibility of a dynamic, tag‑based approach. In this guide, I demonstrated both methods to help you decide which best suits your needs. With the dynamic method, you can keep your Teams notifications current without constant manual updates, ensuring your teams always communicate effectively when key ERP events occur.

If you have any questions or need further assistance in customizing your solution, feel free to reach out.