bcquality/microsoft/knowledge/events/name-events-by-publisher-position.bad.al
Jesper Schulz-Wedde faeacb2484 Add 12 general AL event-design articles to events domain
Add 12 atomic knowledge articles under microsoft/knowledge/events covering
general AL event-design best practices: IsHandled initialization and OnAfter
preservation, appending new event parameters, position-based event naming,
reusing/extending events, avoiding per-iteration publishing, Temp-prefixing
temporary record parameters, unabbreviated parameter names, preferring the
this keyword over IncludeSender, avoiding loosely typed parameters, not
mutating existing event contracts, and not bypassing critical operations
with IsHandled. Each article ships a .good.al and .bad.al demonstration
sample (object IDs 50240-50296; not compiled by CI). Extend the
al-events-review leaf Worklist with one targeted check per new rule.

Additive only; no contract or wiring change (events leaf already wired).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-25 11:58:59 +02:00

35 lines
1 KiB
AL

// Demonstration-only AL. Not compiled by CI; illustrates the article.
codeunit 50256 "Event Naming Bad Sample"
{
procedure PostSalesLine(var SalesLine: Record "Sales Line")
var
LineAmount: Decimal;
begin
// Anti-pattern: names don't encode the host routine or the
// before/after position, so subscribers can't tell when they fire.
BeforePost(SalesLine);
LineAmount := SalesLine.Quantity * SalesLine."Unit Price";
MyCustomSalesEvent(SalesLine, LineAmount);
SalesLine."Line Amount" := LineAmount;
SalesLine.Modify(true);
SalesLineEvent(SalesLine);
end;
[IntegrationEvent(false, false)]
local procedure BeforePost(var SalesLine: Record "Sales Line")
begin
end;
[IntegrationEvent(false, false)]
local procedure MyCustomSalesEvent(var SalesLine: Record "Sales Line"; var LineAmount: Decimal)
begin
end;
[IntegrationEvent(false, false)]
local procedure SalesLineEvent(var SalesLine: Record "Sales Line")
begin
end;
}