Finding the right event can be a hunt, even for seasoned MVPs. Yet, the Event Recorder is often an overlooked feature. In this video, I show how easy it is to locate events using the Event Recorder. Check it out:

Ever wonder how experienced AL developers find the right events to subscribe to in Business Central? Erik conducted a “very scientific survey” of the MVPs in his house and found that while all of them hunt for events, only about half actually use the built-in Event Recorder. This video walks through exactly how the Event Recorder works and demonstrates a practical example of subscribing to an event on the sales document release process.
What Is the Event Recorder?
The Event Recorder is a built-in tool in Business Central that captures every event that fires during a specific user action. It’s perfect for those moments when you know what you want to hook into — like the release of a sales order — but you’re not sure where that event lives. Is it on the page? On a codeunit? On a table? The Event Recorder answers that question by recording everything that happens behind the scenes.
How to Use the Event Recorder
Step 1: Open and Tear Out
Search for “Event Recorder” in Business Central. Once it’s open, Erik recommends using the tear out feature (pop it into its own browser window). This is important: the torn-out window is still part of the same session, so it will capture events from your main window. Opening a separate browser tab would create a different session entirely.
Step 2: Start Recording
Click Start on the Event Recorder. Nothing visually changes — the recorder is now silently capturing every event that fires in your session.
Step 3: Perform Your Action
Go back to your main window and perform the action you want to investigate. In this example, Erik navigates to a sales order and clicks Release. The order releases as normal — nothing different from the user’s perspective.
Step 4: Stop and Analyze
Go back to the Event Recorder window and click Stop. In this example, 170 events were recorded for a single release action. That might sound overwhelming, but you can quickly narrow things down:
- Sort by Call Order to see the sequence of events as they actually fired
- Filter by Object — if you know the event should be in the “Release Sales Document” codeunit, filter on that
- Ignore the tail end — events firing after the action completes (like page refreshes) can be disregarded
Erik’s Quick Trick for Finding the Right Event
Erik shared a simple heuristic: the shorter the event name, the more likely it’s a high-level event. An event called OnBeforeReleaseSalesDoc is probably what you want. Something like OnCodeOnAfterCalcShouldSetStatusPrepayment sounds like it’s deep in the weeds. This isn’t a hard rule, but it’s a useful mental shortcut when scanning through dozens of recorded events.
Grabbing the AL Snippet
Here’s one of the best features of the Event Recorder: once you’ve identified the event you want, scroll right in the recorded events list and you’ll find an AL Snippet column. Click on it, and Business Central gives you a ready-made code snippet that you can paste directly into Visual Studio Code.
The snippet gives you the [EventSubscriber] attribute with all the correct parameters filled in. The procedure body and parameters are left for you to complete.
Building the Event Subscriber
After pasting the snippet into VS Code, Erik recommends naming the procedure the same as the event for clarity. To discover the available parameters, place your cursor inside the empty parentheses and press Ctrl+Space (or Ctrl+Shift+Space) to see what parameters the event exposes.
An important note: you don’t have to include all parameters. If the event exposes four parameters but you only need the Sales Header, just include that one. Also, the order of parameters doesn’t matter — as long as the names and types match, AL will wire them up correctly.
Here’s the complete example that prevents releasing a sales order on a Sunday:
codeunit 50112 "Event Recorder Demo"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Release Sales Document", 'OnBeforeReleaseSalesDoc', '', true, true)]
local procedure OnBeforeReleaseSalesDoc(var SalesHeader: Record "Sales Header"; PreviewMode: Boolean)
begin
if PreviewMode then
exit;
if Date2DWY(SalesHeader."Posting Date", 1) = 7 then
error('No posting dates on a Sunday!');
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Release Sales Document", 'OnBeforeOnRun', '', true, true)]
local procedure MyProcedure()
begin
end;
}
How the Code Works
- The
[EventSubscriber]attribute hooks into theOnBeforeReleaseSalesDocevent on theRelease Sales Documentcodeunit - If we’re in Preview Mode, we exit early — no need to block preview operations
- The
Date2DWYfunction extracts the day of the week (parameter1) from the posting date. A return value of7means Sunday - If it’s Sunday, an error is raised, which prevents the release from completing
Note the second subscriber to OnBeforeOnRun — Erik pointed this out as an interesting naming curiosity. The event fires before the OnRun trigger of the codeunit, so “OnBeforeOnRun” is technically accurate, even if it reads a bit oddly. Not every event name makes perfect intuitive sense, which is part of why the Event Recorder is so valuable — you can see exactly when each event fires in the call sequence.
Summary
The Event Recorder is a powerful, underutilized tool built right into Business Central. Instead of guessing which events exist or manually browsing through base application source code, you can simply record an action and see every event that fires. The AL snippet feature makes it even faster to go from discovery to implementation. Whether you’re a seasoned MVP or just getting started with AL development, the Event Recorder can save you significant time when hunting for the right event to subscribe to.