Asked Aug 2026
Question
Where should event subscribers live in an AL extension when multiple features need independent handlers? I want the structure to remain testable and easy to discover.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostSalesDoc', '', false, false)]
local procedure HandlePostedDocument()
begin
// feature behavior
end;Answer 1
Group subscribers by business responsibility rather than putting every event in one global codeunit. Keep handlers small and delegate complex work to testable services.
✓ Verified answer
Create feature-oriented subscriber codeunits, use meaningful names, avoid state, and move reusable logic behind focused procedures or interfaces. This keeps permissions, tests and ownership clearer.
Answer 3
Also document why each subscriber exists and include automated tests for filters, order-sensitive behavior and failure paths.