Core utilization
Business events provide our partners and customers a mechanism for notifying and triggering their external systems (Dataverse and non-Dataverse) when actions are done on Business Central.
The external systems can react and perform other actions in response. With Dataverse, partners and customers can use Power Automate to subscribe to Business Central for its business events and react on other apps in its ecosystem, such as Dynamics 365 Sales or Customer Service, and others built using Power Apps.
Other implementations
They can also react on non-Dataverse systems, such as non-Microsoft warehouse management, fulfillment, and e-invoicing services.
Etc. etc.
Current limitations and future improvements
This feature has the following limitations that will be either removed or improved on in a future update:
Run in All Companies
- When creating Power Automate flows with the When an action is performed trigger, you can’t select specific companies to subscribe for their business events, so business event subscriptions are submitted for all companies accessible to you for now
No Translation & Versioning
- Translation and versioning for business events aren’t supported for now
Business Events Schema
** TESTING BUSINESS EVENTS **
Testing Flow
- Activate Dataverse for Business Events handling
- Create Business Events in AL Code
- Publish & Refreshing Business Events in Power Apps
- Create a Flow using Dataverse Business Events
Dataverse Setup
Check Environments
Install Virtual Table (if not installed)
Activate “Enable Virtual Tables & Events (Business Events)
AL Code Example
Creation of a Business Event in AL code
Extend EventCategory in AL Code
Identify existing categories for your custom business events or create new ones using the extensible enum “EventCategory”
- (example for: “Sales” declaration)
enumextension 50161 MyExtEventCategory extends EventCategory
{
value(50002; “My Sales Events”)
{
Caption = ‘My Sales Events’;
}
}
Create a Business Event in AL Code
Create a procedure with an empty body for each custom business event
- Add the ExternalBusinessEvent attribute to define the business event name, display name, description, and category
- Add the optional RequiredPermissions attribute to enforce more permissions for users to subscribe
- Add the required parameters to define the business event payload
// EXT_BUSINESS_EVENT::”SALESORDERELEASED”
[ExternalBusinessEvent(‘SalesOrderReleased’, ‘Sales order released’, ‘This business event is triggered when a sales order is released’,
EventCategory::”My Sales Events”)]
[RequiredPermissions(PermissionObjectType::TableData, Database::”Sales Header”, ‘R’)] // optional
// Business Event Name : “MyBusinessEventSalesOrderReleased”
local procedure MyBusinessEventSalesOrderReleased(SalesOrderID: Guid; SalesOrderUrl: text[250])
begin
end;
Subscribe to an event, in this case: ‘OnAfterReleaseSalesDoc’
Identify a specific AL event to subscribe and invoke the custom business event procedure with appropriate parameters when it occurs
// Subcription to ‘OnAfterReleaseSalesDoc’
[EventSubscriber(ObjectType::Codeunit, Codeunit::”Release Sales Document”, ‘OnAfterReleaseSalesDoc’, ”, true, true)]
local procedure OnAfterReleaseSalesDoc(var SalesHeader: Record “Sales Header”; PreviewMode: Boolean; var LinesWereModified: Boolean)
var
Url: Text[250];
SalesOrderApiUrlTok: Label ‘v2.0/companies(%1)/salesOrders(%2)’, Locked = true;
Begin
//Check Order Status = ‘RELEASED’ 🡪 Run Business Event
if SalesHeader.Status = SalesHeader.Status::Released then begin
Url := GetBaseUrl() + StrSubstNo(SalesOrderApiUrlTok, GetCompanyId(), TrimId(SalesHeader.SystemId));
MyBusinessEventSalesOrderReleased(SalesHeader.SystemId, Url); //Business Event
end;
end;
Build YOUR APP
To build and install an extension that implements custom business events
- Compile and publish your APP on Business Central Tenant
.. AND NOW … TESTING BUSINESS EVENTS IN POWER APPS
Create a Microsoft Dataverse Connection
Refresh Dataverse Tables
Refreshing “Business Central Events” on Dataverse
- Choose your Business Central Configuration
Launch “Refresh Business Central Business Events”
CREATE A NEW FLOW (AUTOMATE)
- Creation for a Cloud Automated Flow
- Choose your connections
This example is related to Dataverse Table “SalesOrder” that contain alle Sales order existing in Business Central
Choose your Dataverse Business Event
Dataverse
- Example : “Sales Order released” action defined in “My Sales Events” Category
Add others steps..
Example
Post & Ship Sales Order after previous step – ActionInput as Parameter
..and now (3 July 2023).. Business events are available directly from “Business Central Connector”
example: Sales Order Released (Microsoft)
