mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-07 09:56:52 +01:00
Correct wording in five events articles to reflect that AL event subscribers bind by parameter name, not position: - add-new-event-parameters-at-the-end: drop the inaccurate claim that appending a parameter forces subscribers to be updated or causes wrong values; keep the append-at-end best practice. - do-not-add-ishandled-to-an-existing-event: reframe from "breaking change" to the semantic/purpose shift that leaves existing subscribers pointless; rename the breaking-change keyword to semantic-change. - name-events-by-publisher-position: extend the good sample with position-named publishers raised from table and report trigger contexts. - initialize-ishandled-to-false-before-publishing: scope the detection and best practice to events that actually carry a var IsHandled, so an OnBefore with no IsHandled is not flagged. - do-not-bypass-critical-operations-with-ishandled: add a litmus-test definition of a critical operation (code that cannot stand as an independent, self-contained unit). Knowledge-only; no contract or wiring change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
64 lines
2.1 KiB
AL
64 lines
2.1 KiB
AL
// Demonstration-only AL. Not compiled by CI; illustrates the article.
|
|
codeunit 50255 "Event Naming Good Sample"
|
|
{
|
|
procedure PostSalesLine(var SalesLine: Record "Sales Line")
|
|
var
|
|
LineAmount: Decimal;
|
|
begin
|
|
// Start of the routine: OnBefore<Name>.
|
|
OnBeforePostSalesLine(SalesLine);
|
|
|
|
LineAmount := SalesLine.Quantity * SalesLine."Unit Price";
|
|
// Middle of the routine: On<Name>OnAfter<Context>.
|
|
OnPostSalesLineOnAfterCalcAmounts(SalesLine, LineAmount);
|
|
|
|
SalesLine."Line Amount" := LineAmount;
|
|
SalesLine.Modify(true);
|
|
|
|
// End of the routine: OnAfter<Name>.
|
|
OnAfterPostSalesLine(SalesLine);
|
|
end;
|
|
|
|
[IntegrationEvent(false, false)]
|
|
local procedure OnBeforePostSalesLine(var SalesLine: Record "Sales Line")
|
|
begin
|
|
end;
|
|
|
|
[IntegrationEvent(false, false)]
|
|
local procedure OnPostSalesLineOnAfterCalcAmounts(var SalesLine: Record "Sales Line"; var LineAmount: Decimal)
|
|
begin
|
|
end;
|
|
|
|
[IntegrationEvent(false, false)]
|
|
local procedure OnAfterPostSalesLine(var SalesLine: Record "Sales Line")
|
|
begin
|
|
end;
|
|
|
|
// Same position-naming convention applies to events raised from table and
|
|
// report triggers, not just codeunit procedures.
|
|
|
|
// Raised at the end of a table field's OnValidate trigger (for example
|
|
// Customer."No." OnValidate): the position is "after", so OnAfter<Field>.
|
|
procedure HandleCustomerNoValidated(var Customer: Record Customer)
|
|
begin
|
|
OnAfterValidateCustomerNo(Customer);
|
|
end;
|
|
|
|
[IntegrationEvent(false, false)]
|
|
local procedure OnAfterValidateCustomerNo(var Customer: Record Customer)
|
|
begin
|
|
end;
|
|
|
|
// Raised before a report prints a line from its processing trigger (for
|
|
// example a dataitem OnAfterGetRecord): the position is "before", so
|
|
// OnBefore<Action>.
|
|
procedure HandleReportLineProcessing(var SalesLine: Record "Sales Line")
|
|
begin
|
|
OnBeforeReportPrintLine(SalesLine);
|
|
end;
|
|
|
|
[IntegrationEvent(false, false)]
|
|
local procedure OnBeforeReportPrintLine(var SalesLine: Record "Sales Line")
|
|
begin
|
|
end;
|
|
}
|