ADVERTISEMENT
Solved Community Question

How should I structure AL event subscribers?

A mockup-authored Q&A example showing evidence, alternatives and a verified solution.

  • AL Development
  • Intermediate
  • 3 Answers
  • Solved

Public UI preview only. Posting, voting and account actions require the future community service.

AK
Arun Kumar
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;
ADVERTISEMENT
AV
Amit Verma
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.

PS
Priya Sharma
✓ 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.

Recommended structure: one subscriber codeunit per feature boundary, with separate implementation codeunits for reusable business logic.
RM
Rahul Mehta
Answer 3

Also document why each subscriber exists and include automated tests for filters, order-sensitive behavior and failure paths.

ADVERTISEMENT

Stay Updated

Get the latest tutorials, tips and resources delivered to your inbox.

ADVERTISEMENT
ADVERTISEMENT