mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 17:36:53 +01:00
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>
27 lines
1 KiB
AL
27 lines
1 KiB
AL
// Demonstration-only AL. Not compiled by CI; illustrates the article.
|
|
codeunit 50261 "Reuse Event Bad Sample"
|
|
{
|
|
procedure ProcessOrder(var SalesHeader: Record "Sales Header"; CustomerNo: Code[20])
|
|
var
|
|
IsHandled: Boolean;
|
|
begin
|
|
IsHandled := false;
|
|
// Anti-pattern: a near-duplicate event raised right next to the original,
|
|
// differing only by an extra parameter — two consecutive events where a
|
|
// single extended event would do.
|
|
OnBeforeProcessOrder(SalesHeader, IsHandled);
|
|
OnBeforeProcessOrderWithCustomer(SalesHeader, CustomerNo, IsHandled);
|
|
if IsHandled then
|
|
exit;
|
|
end;
|
|
|
|
[IntegrationEvent(false, false)]
|
|
local procedure OnBeforeProcessOrder(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)
|
|
begin
|
|
end;
|
|
|
|
[IntegrationEvent(false, false)]
|
|
local procedure OnBeforeProcessOrderWithCustomer(var SalesHeader: Record "Sales Header"; CustomerNo: Code[20]; var IsHandled: Boolean)
|
|
begin
|
|
end;
|
|
}
|