bcquality/microsoft/knowledge/events/use-ishandled-to-make-base-behaviour-overridable.good.al
Jesper Schulz-Wedde 5706959e4a
Fix lifecycle compatibility guidance (#93)
* Fix lifecycle compatibility guidance

Correct high-confidence Business Central guidance and samples for upgrade tags, collectible errors, trigger semantics, obsoletion, events, interfaces, API contracts, and test transactions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e05a43e7-6448-4d67-9c73-798523f5d945

* Address guidance review findings

Gate SecretText guidance to BC23 and clarify that the collectible-error sample intentionally emits a message-only blocking aggregate.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e05a43e7-6448-4d67-9c73-798523f5d945

---------

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
2026-07-14 11:26:16 +02:00

38 lines
1.3 KiB
AL

// Demonstration-only AL. Not compiled by CI; illustrates the article.
codeunit 50220 "Shipping Charge Good Sample"
{
procedure CalculateShippingCharge(OrderAmount: Decimal) Charge: Decimal
var
IsHandled: Boolean;
begin
// Give extensions a sanctioned seam to replace the calculation, then
// skip the default logic when a subscriber has handled it.
IsHandled := false;
OnBeforeCalculateShippingCharge(OrderAmount, Charge, IsHandled);
if IsHandled then
exit(Charge);
if OrderAmount >= 1000 then
Charge := 0
else
Charge := 49;
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeCalculateShippingCharge(OrderAmount: Decimal; var Charge: Decimal; var IsHandled: Boolean)
begin
end;
}
codeunit 50221 "Shipping Charge Sub Good Sample"
{
// A partner replaces the flat rate with a contract-specific rule.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Shipping Charge Good Sample", 'OnBeforeCalculateShippingCharge', '', false, false)]
local procedure ApplyContractRate(OrderAmount: Decimal; var Charge: Decimal; var IsHandled: Boolean)
begin
if IsHandled then
exit;
Charge := OrderAmount * 0.02;
IsHandled := true;
end;
}