Using events
Events in Business Central AL development: event types, publishing, raising and subscribing, isolated events, discovering events with Event Recorder, deprecating external business events, UI notifications, and a workflow events walkthrough. It answers how to extend application behavior through events.
- 10Learn pages
- 1videos
Path: Development > Extensibility > Using events · tier official · system development · narrative reviewed (checked by Opus)
Overview
Events let components communicate in a loosely coupled way. A publisher defines an event, code raises it by calling the publisher method, and subscribers react with custom logic. The section covers the full cycle: the kinds of events (business, integration, global, database and page trigger events), how to publish them, how to raise them, and how to subscribe with the EventSubscriber attribute.
Start with Event types and Event example for the concepts, then Publishing Events, Raising Events and Subscribing to events for the mechanics. Events discoverability shows how to use the Event Recorder to find which events to subscribe to. Isolated events explain error handling when a subscriber fails.
Further pages cover related tasks: deprecating external business events so integrations can move to replacements, showing nonintrusive UI messages with the Notification data type, and a walkthrough that implements new workflow events and responses.
Key points
- Event types include business events, integration events, global events, and database and page trigger events.
- Publisher methods are created in AL objects such as codeunits, pages and tables, using the BusinessEvent or IntegrationEvent attribute.
- Subscribers use the EventSubscriber attribute; the EventSubscriberInstance property is also covered.
- Event Recorder captures events while a scenario runs and generates AL snippets for subscribing.
- Isolated events let the publisher continue if a subscriber fails; the subscriber’s errors are rolled back without affecting others.
- External business events are deprecated by marking them obsolete pending first and removing them in a later version (page lists version 27.0), using the Obsolete and ExternalBusinessEvent attributes and a DisplayName prefix.
- Notifications use the Notification data type with Message, Scope, Send, AddAction, SetData and GetData methods in the web client.
- A walkthrough shows how to add new workflow events and responses by registering them through event subscribers.
Learn pages
- Deprecate external business events: Learn how to deprecate external business events in AL for Business Central.
- Event example: This article shows a simple example of how to use events in Business Central.
- In the observatory: Page 21 “Customer Card”
- Event types: Business Central supports different types of events including BusinessEvent, IntegrationEvent, Global, and trigger events.
- Events discoverability: Using the Event Recorder, you can record the events that are published and raised while performing the actions of your scenario.
- In the observatory: Page 9845 “Event Recorder”
- Isolated events in AL: Describes how isolated events work in Business Central.
- Notifications: Learn how to use notifications in the development environment to send nonintrusive information to the user interface in Business Central.
- Publishing Events: This article describes how to create an event publisher method to publish business and integration events.
- Raising Events: This article describes how to modify the application to raise an event in Dynamics 365 Business Central.
- In the observatory: Codeunit 741 “VAT Report Release/Reopen”
- Subscribing to events: Designing event subscribers in AL for Business Central.
- Walkthrough: Implementing New Workflow Events and Responses: Learn how you can extend the native workflows by adding workflow events and responses in code to support additional business scenarios.
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #10156 [Bug][SubscriptionBilling] Assign Subscription Lines dialog does not identify the sales line it was opened for (code change): “New event OnAfterGetAssignSubscriptionLinesCaption lets extensions customize the caption”
- #10167 [Extensibility Request] issue 30240: add event before adding price list lines (code change): “A cancellable event is added before price list line creation so extensions can implement”
- #10169 [Extensibility Request] issue 30081: add VAT registration number override event (code change): “New OnBeforeGetVATRegNo integration event in GetVATRegNo of IntrastatReportManagement”
- #10235 [Bug][SubscriptionBilling] Enforce Subscription Line Start Date change rules on all edit paths (code change): “Provides extensibility hook via OnAfterCheckSubscriptionLineStartDateChangeAllowed event”
- #10487 Add integration event before inserting the cost allocation journal line (code change): “New integration event OnWriteJournalLineOnBeforeInsertTempCostJournalLine added to Cost Allocation report”
- #10488 Add integration event before inserting the outgoing IC sales line buffer (code change): “New event OnPostICSalesLineToICPartnerInboxOnBeforeBufferICInboxSalesLineInsert fires per sales line”
- #11380 Honor explicit 0% discounts in Sales and Purchase price lists (code change): “Honor explicit 0% discounts in Sales and Purchase price lists preserving subscriber vetoes”
- #11580 [Extensibility Request] issue 29654: customize document rejection response (code change): “Enables extensions to define custom rejection states. Preserves default open document behavior”
- #11664 Add OnBefore event for approval insertion checks (code change): “An integration event is added to the Approvals Mgmt. codeunit that allows extensions to skip journal insertion approval checks”
- #13326 [Fabric] Clean up test events, app naming, authentication and telemetry (code change): “Five test-only IsHandled events in Fabric Platform”
- #14738 [Main][All-E] Vendor Bank Account Approval Workflow: Approve/Reject/Delegate events cannot be re-added after deletion (code change): “Approve, Reject, and Delegate events in Vendor Bank Account Approval Workflow could not be re-added after deletion”
- #8771 Add OnBeforeFilterRemovedSourceRecords integration event in Email Impl (code change): “Adds an OnBeforeFilterRemovedSourceRecords integration event with an IsHandled guard”
- #9067 Production Definition Wizard - Implementation (code change): “Event publishers expanded with new parameters and integration points like OnBeforeGetProdOrderNeeds”
- #9077 [Quality Management] Bug 620326: Reset IsChangingStatus on handled Reopen/Finish early-exit (code change): “Quality Management’s Reopen/Finish procedures now properly reset the IsChangingStatus flag”
- #9225 [Extensibility][SubscriptionBilling]: Make usage data billing filtering extensible in SetUsageDataBillingFilters (code change): “Added OnAfterSetUsageDataBillingFilters integration event for extensibility”
- #9637 [Event Requests] Add integration events across base app and SMTP module (code change): “adding new integration events or extra parameters on existing ones”
- #9950 [Master] - Bug 645038 Withholding Tax entries from a previous posting preview appear on unrelated documents (e.g. expense report) (code change): “Withholding Tax entries from a previous posting preview appear on unrelated documents”
- #139 knowledge(breaking-changes): adding a parameter to an event publisher is not a signature break (code change): “Event subscribers bind to publishers by parameter name, not by position”
- #144 Avoid Public Event publisher (code change): “event publishers local or internal instead of public”
- #145 Process Context via manual event subscriber pattern (code change): “expose process context to extensions using manual event subscriber bindings”
- #213 knowledge(events): database trigger setup flags may only be set to true (code change): “subscribers to GetDatabaseTableTriggerSetup should only set the shared trigger flags to true”
- #223 knowledge(data-modeling): code that calculates a unit price rounds it to the currency’s Unit-Amount Rounding Precision (code change): “Subscribers that handle OnUpdateUnitPriceOnBeforeFindPrice or OnUpdateDirectUnitCostOnBeforeFindPrice”
- #281 fix: align READ domain examples and the event parameter addition article (code change): “subscribers never break at any position; the only exception is callers”
- #289 workflow-library-registration (code change): “custom workflow events, responses and table relations should be registered through the workflow library”
- #98 Add P0 event and interface compatibility knowledge (code change): “Event parameter compatibility rules clarified: local/internal subscribers bind by name”
- Obsoleted and “no longer invoked” events in v26 Business Central (community post): “82 obsoleted events from the legacy invoice posting system”
- Dynamics 365 Business Central: Save a document as a Word attachment (Attach as Word) – Customization (community post): “Event subscribers can hook into OnBeforeSaveReportAsPDF and OnBeforeSaveAttachment to modify the standard behavior”
- Dynamics 365 Business Central: How to automatically archive sales orders via AL (For example, Archive on Order Release) (community post): “subscribing to the release event and calling the ArchiveManagement codeunit”
- Dynamics 365 Business Central: How to set Company Badge (System Indicator) via AL Code – Automatically set Company Badge (community post): “subscribe to the GetSystemIndicator business event to set company badges programmatically”
- Dynamics 365 Business Central: How to flow/pass custom field values from Sales Order to Production Order (community post): “Subscribe to standard events without modifying core codeunit logic”
- Dynamics 365 Business Central: How to add a setup to the Manual Setup (1875, List) page (community post): “Subscribe to the OnRegisterManualSetup event to add new manual setups”
- Business Central Under the Hood episode 6: We Have Too Many Events! (video): “Integration Events; Workflow Events; Event Usage Telemetry; Handled events”
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.