bcquality/microsoft/knowledge/events/initialize-ishandled-to-false-before-publishing.good.al
wenjiefan 5f1cff2fb6 Refine self-improvement review guidance
Narrow IsHandled, label-scope, UI-handler, checkpoint, and bulk-operation guidance to evidence-backed false-positive boundaries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-18 11:17:14 +02:00

31 lines
1.1 KiB
AL

// Demonstration-only AL. Not compiled by CI; illustrates the article.
codeunit 50240 "IsHandled Init Good Sample"
{
procedure ApplyDiscounts(var SalesHeader: Record "Sales Header")
var
DiscountPct: Decimal;
IsHandled: Boolean;
begin
// A freshly declared local Boolean is false.
OnBeforeApplyHeaderDiscount(SalesHeader, DiscountPct, IsHandled);
if IsHandled then
exit;
DiscountPct := 5;
// Reaching this point proves that IsHandled is still false.
OnBeforeApplyPaymentDiscount(SalesHeader, DiscountPct, IsHandled);
if IsHandled then
exit;
DiscountPct += 2;
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeApplyHeaderDiscount(var SalesHeader: Record "Sales Header"; var DiscountPct: Decimal; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeApplyPaymentDiscount(var SalesHeader: Record "Sales Header"; var DiscountPct: Decimal; var IsHandled: Boolean)
begin
end;
}