Business Central 2022 wave 1 (BC20) new features: Isolated events and New isolated event OnCompanyOpenCompleted

Dynamics 365 Business Central

Hi, Readers.
Dynamics 365 Business Central 2022 release wave 1 (BC20) is generally available. Learn more: Link.

I will continue to test and share some new features that I hope will be helpful.

Isolated events:

Business value:

AL developers can raise an event that is guaranteed to invoke all event subscribers—even if some subscribers fail—and continue executing.

Feature details:

Extensions shouldn’t be able to block critical processes such as sign-in or opening role centers.

A failing extension should result in a degraded experience—not no experience at all.

Isolated events work like Codeunit.Run:
・Each subscriber is executed in its own transaction.
・Failures cause the transaction to be rolled back.
・Errors are trapped and execution continues.

https://docs.microsoft.com/en-us/dynamics365-release-plan/2022wave1/smb/dynamics365-business-central/isolated-events

This new feature is also mentioned in AL Language changelog Version 9.0.

New Isolated event attribute

Events definitions now support an isolated mode, in which they will be executed with isolated transaction schematics. Allowing all events to be executed, even if one fails, and allow the calling code to also continue executing.Events definitons now support an isolated mode, in which they will be executed with isolated transaction schematics. Allowing all events to be executed, even if one fails, and allow the calling code to also continue executing.

Let’s see more details. Now a new parameter (Isolated) has been added to IntegrationEvent Attribute, BusinessEvent Attribute and InternalEvent Attribute.

[Optional] Isolated
 Type: Boolean
Specifies if event subscribers should be invoked in an isolated transaction.

For example, you can find a new isolated event OnCompanyOpenCompleted in codeunit 2000000003 “Company Triggers”.

In fact, this event is also a new feature of Business Central 2022 wave 1 (BC20).

New isolated event OnCompanyOpenCompleted:

Business value:

This event is raised after sign-in and company open have completed. Any subscribers to this event can fail but will not block the sign-in process.

Feature details:

Without this event, extensions can break the sign-in process.

The OnCompanyOpenCompleted event is raised during sign-in, when trying to open the company. It is of type Isolated, which means that a failure in a subscriber cannot propagate to blocking the sign-in process.

https://docs.microsoft.com/en-us/dynamics365-release-plan/2022wave1/smb/dynamics365-business-central/new-isolated-event-oncompanyopencompleted

Another example, OnAfterLogin() in codeunit 150 “System Initialization”.

For better understanding, let’s look at a simple example.

I created a new page, added an isolated event on it, and let it execute in the OnOpenPage Trigger.

Then subscribe to this isolated event in the codeunit and throw an error on purpose.

Because it’s an isolated event, it won’t be blocked when I open the page. But we can see this error in the last known error.

Test Video:

But if the Isolated is false, an error will be prompted on the page.

Test Video:

In conclusion, Isolated events can make the system more secure, and will not cause serious situations such as the Business Central being unable to log in due to an extension. Give it a try!!!😁

More details about Isolated Events in AL.

Update info from Dynamics 365 Business Central Launch Event 2022 Release Wave 1:

END

Hope this will help.

Thanks for reading.

ZHU

コメント

タイトルとURLをコピーしました