Business Central 2023 wave 1 (BC22) new features: Event navigability

Dynamics 365 Business Central

Hi, Readers.
The public preview for Dynamics 365 Business Central 2023 release wave 1 (BC22) is available. Learn more: Link.

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

In this post, I would like to talk about Event navigability. This new feature is not mentioned in the 2023 wave1 release plan, but it is in Business Central Launch Event (2023 release wave 1).

As you might know, you create an event subscriber method just like other methods except that you specify properties that set up the subscription to an event publisher. The procedure is slightly different for database and page trigger events than business and integration events. Business and integration events are raised by event publisher methods in application code. Trigger events are predefined system events that are raised automatically on tables and pages.
For example,

More details: Subscribing to Events

ArgumentDescriptionOptional
<Event Publisher Object Type>Specify the type of object that publishes the event. This argument can be CodeunitPageReportTable, or XMLPort.no
<Event Publisher Object>Specify the object that publishes the event. You can set this argument to the ID, such as 50100, or the recommended way is to use the object name by using the syntax <Object Type>::"<Object Name>", such as Codeunit::"MyPublishers", or for database triggers Database::"Customer".no
<Published Event Name>Specify the name of method that publishes the event in the object that is specified by the <Event Publisher Object> parameter.no
<Published Event Element Name>Specifies the table field that the trigger event pertains to. This argument only requires a value for database trigger events, that is, when the <Event Publisher Object Type> is set to Table and the <Published Event Name> argument is a validate trigger event, such as OnAfterValidateEvent.no
<SkipOnMissingLicense>Set to true to skip the event subscriber method call if the user’s license doesn’t cover the event subscriber codeunit. If false, an error is thrown and the code execution stops. false is the default.yes
<SkipOnMissingPermission>Set to true to skip the event subscriber method call if the user doesn’t have the correct permissions the event subscriber codeunit. If false, an error is thrown and the code execution stops. false is the default.yes

And, so far event subscriber arguments has been using string literals, and no navigability.
‘<eventpublishername>'(single quotes): ‘OnAfterConfirmPost’

With this release, this has changed, event subscriber arguments now use identifier syntax.👏👏👏
<eventpublishername> or “<eventpublishername>”(double quotes): OnAfterConfirmPost

Another example

This means that powerful VS Code navigation features are unlocked.

Let’s see more details.
We can go to difinition (F12) to jump to event publisher.

We can use Go to References (Shift + F12) to see all uses.

We can see the tooltip on event publisher name in event subscriber.

Microsoft has also prepared new AL Code Actions to convert the name. You can run on specific EventSubscriber instace, active file, active project, or workspace.
More details: Using AL Code Actions

Very nice! Give it a try!!!😁

Business Central Launch Event (2023 release wave 1) 
Session: What’s new in VS Code and AL (It is recommended to check out the Business Central Launch Event directly to learn more about new features)

The 2023 wave 1 release plan has been updated.
Code navigability on event subscribers

Events are a core concept of extensibility in AL. Until today, the event publisher parameter in event subscribers has been allowing string literals only. Due to this, the target reference has not been known in the AL authoring context, with the result that a developer hasn’t been able to use standard Visual Studio Code navigation support such as Go To Definition or see references inline.
Now the parameter supports being an identifier instead, allowing full navigability and increased developer productivity.

https://learn.microsoft.com/en-us/dynamics365/release-plan/2023wave1/smb/dynamics365-business-central/code-navigability-event-subscribers

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL