bcquality/custom/knowledge/integration/version-business-events-and-keep-payloads-stable.bad.al
Tharanga Chandrasekara 07140e2223 Add new action skills for AL testing and documentation
- Introduced `al-test-writer` to generate AL test codeunits for production objects based on TDD principles.
- Added `al-userguide-test-writer` to create test codeunits from user guide steps, mapping actions and assertions.
- Implemented `bc-extension-test-guide` to generate a comprehensive TEST_GUIDE.md for Business Central extensions, covering various categories.
- Created `bc-webclient-runner` to automate UI testing of the Business Central web client, capturing screenshots and asserting UI states.
- Developed `page-scripting-e2e` to produce a recording plan for Page Scripting, ensuring a structured approach to browser-level testing.
2026-06-07 12:26:47 +12:00

30 lines
1.5 KiB
AL

// Anti-pattern: mutating a published signature, passing the whole record plus a secret, and
// firing without validation or failure classification. Every external subscriber breaks, and
// credentials and every table field leak into the payload.
codeunit 50173 "Order Events Bad"
{
// This event already shipped as OnOrderConfirmed(OrderNo: Code[20]). Subscribers bound to
// that signature. Editing it IN PLACE to add parameters silently breaks all of them: there
// is no compiler across the boundary, so the notification just starts arriving in the wrong
// shape and processing fails on the far side, far from this change.
[ExternalBusinessEvent('OrderConfirmed', 'Order confirmed', 'Raised on confirm', EventCategory::Sales)]
procedure OnOrderConfirmed(var SalesHeader: Record "Sales Header"; ApiKey: Text)
// BAD: the full record exposes every field of Sales Header to every subscriber and couples
// the contract to the table layout. ApiKey leaks a secret credential into the payload.
begin
end;
}
codeunit 50174 "Order Publisher Bad"
{
procedure Publish(SalesHeader: Record "Sales Header")
var
Events: Codeunit "Order Events Bad";
begin
// BAD: no validation. A header with no document number is published and then, because
// the data is permanently invalid, retried by the platform indefinitely. There is no
// transient/permanent classification, so an unfixable payload is treated like a blip.
Events.OnOrderConfirmed(SalesHeader, GetSecretApiKey());
end;
}