agent-builder
Agent Toolkit Builder — specialist in designing and coding Business Central agents using the AI Development Toolkit and Agent…
AL event-driven architecture for Business Central. Use when creating EventSubscribers, IntegrationEvents, BusinessEvents, or implementing publisher/subscriber patterns in extensions.
$ npx -y skills add javiarmesto/ALDC-AL-Development-Collection --skill skill-events --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/skill-eventsContext preview
The summary Claude sees to decide when to auto-load this skill.
AL event-driven architecture for Business Central. Use when creating EventSubscribers, IntegrationEvents, BusinessEvents, or implementing publisher/subscriber patterns in extensions.
name: skill-events description: "AL event-driven architecture for Business Central. Use when creating EventSubscribers, IntegrationEvents, BusinessEvents, or implementing publisher/subscriber patterns in extensions."
Discover, design, and implement event-driven patterns in AL Business Central extensions: event discovery via Event Recorder, subscriber/publisher creation, IsHandled patterns, and extensibility design.
This skill should be loaded when:
Before writing any subscriber, discover which events are raised during the business process:
1. Open the Event Recorder in VS Code ← VS Code command (not an agent tool) 2. Start recording 3. Execute the business process in BC (e.g., post a sales order) 4. Stop recording 5. Analyze the event list — filter by object or keyword 6. Identify the OnBefore/OnAfter event closest to your extension point
Use `al_search_objects` and `al_get_object_definition` to inspect publisher signatures. Use `al_find_references` to see who else subscribes to the same event.
// Subscriber codeunit — name with "Handler" suffix
codeunit 50100 "Sales Document Events Handler"
{
// Attribute breakdown:
// ObjectType — Table, Codeunit, Page, Report, etc.
// ObjectId — Database::"Sales Header" or Codeunit::"Customer Management"
// EventName — exact name of the publisher procedure (e.g., OnBeforeInsert)
// ElementName — '' for table/codeunit events; field name for page field triggers
// SkipOnMissingLicense — false (recommended: always run)
// SkipOnMissingPermission — false (recommended: always run)
[EventSubscriber(ObjectType::Table, Database::"Sales Header",
OnBeforeInsert, '', false, false)]
local procedure OnBeforeInsertSalesHeader(
var SalesHeader: Record "Sales Header";
RunTrigger: Boolean)
begin
ValidateCustomFields(SalesHeader);
end;
}**Subscriber rules:**
The standard extensibility pattern: `OnBefore` allows interception, `OnAfter` allows reaction.
codeunit 50101 "Customer Management"
{
procedure CreateCustomer(var Customer: Record Customer): Boolean
var
IsHandled: Boolean;
begin
// 1. Raise OnBefore — subscribers can validate, modify, or skip
OnBeforeCreateCustomer(Customer, IsHandled);
if IsHandled then
exit(true);
// 2. Default logic
if not Customer.Insert(true) then
exit(false);
// 3. Raise OnAfter — subscribers can react (logging, integration, etc.)
OnAfterCreateCustomer(Customer);
exit(true);
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeCreateCustomer(
var Customer: Record Customer;
var IsHandled: Boolean)
begin
// Empty body — subscribers provide the implementation
// IsHandled = true → skip default logic
end;
[IntegrationEvent(false, false)]
local procedure OnAfterCreateCustomer(var Customer: Record Customer)
begin
// Empty body — subscribers react after creation
end;
}**IntegrationEvent attribute:**
Business events are user-disablable — use for optional, non-critical functionality:
[BusinessEvent(IncludeSender)]
local procedure OnCustomerCreditLimitExceeded(
Customer: Record Customer;
RequestedAmount: Decimal)
begin
// Subscribers may send notification, log, or block — user can disable
end;| Attribute | Cannot be disabled | Use for | |---|---|---| | `IntegrationEvent` | Correct | Critical business logic, posting interventions | | `BusinessEvent` | Can be disabled by user | Optional features, external integrations, notifications |
// ✅ Good — rich context, var where modification expected, IsHandled for OnBefore
[IntegrationEvent(false, false)]
local procedure OnBeforePostDocument(
var DocumentHeader: Record "Sales Header"; // var — subscriber may modify
var DocumentLines: Record "Sales Line"; // var — subscriber may modify
PostingDate: Date; // value — read-only context
var IsHandled: Boolean) // var — subscriber may skip default
begin
end;
// ✅ Good — results context for OnAfter
[IntegrationEvent(false, false)]
local procedure OnAfterPostDocument(
DocumentHeader: Record "Sales Header"; // value — read-only (already posted)
PostedDocumentNo: Code[20]; // result reference
PostingResult: Boolean) // success/failure
begin
end;**Parameter design rules:**
Skills-based, spec-driven, TDD-orchestrated development framework for Microsoft Dynamics 365 Business Central. Engineering systems, visibly reasoned.
Agent Toolkit Builder — specialist in designing and coding Business Central agents using the AI Development Toolkit and Agent…
Generate optimized natural language instructions for Business Central agents (Designer or SDK). Applies the…
End-to-end workflow to create a coded Business Central agent using the Agent SDK. Orchestrates the 7 phases following the…
Generate optimized natural language instructions for Business Central agents (Designer or SDK). Applies the…
Generate AL code for Business Central Agent SDK task integration. Applies the patterns from skill-agent-task-patterns to produce…
Generate comprehensive test codeunits for Business Central Agent SDK integrations. Covers 6 categories: Registration, Factory,…