web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Event handler vs Chain of command

(0) ShareShare
ReportReport
Posted on by 4,131

Hi experts,

Should the developer always use Chain of Command rather than event handler in X++?

Thanks,

I have the same question (0)
  • Suggested answer
    Komi Siabi Profile Picture
    13,208 Most Valuable Professional on at

    Hello Yuji,

    Take a look at this.

    community.dynamics.com/.../difference-between-coc-and-event-handler-in-d365

  • Yuji Profile Picture
    4,131 on at

    Thanks Komi, to answer my question, there shouldn't be any code written in pre or post event handler since COC is more powerful?

  • Verified answer
    Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    "Always" is a strong word. The right answer is - as usual - "it depends". :-)

    CoC is usually easier and more powerful, but event handlers have some benefits too. You can have a single handler method for multiple events and you also can add handlers at runtime, not just at design-time by attributes.

    It also sometimes makes sense to create a single class with handlers for various objects (such as form controls of a single form) rather then having a separate extension class for each of them.

  • Verified answer
    Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    Regaring pre- and post-method event handlers, they should be avoided whenever possible. CoC is a better way.

    In my previous reply, I meant modeled events such as OnCreated.

  • GirishS Profile Picture
    27,843 Moderator on at

    Hi Yuji,

    I think its depend on the situation and functionality whether to use COC or event handler. In general COC is more powerful since you can access the form and class variables easily without much code.

    Thanks,

    Girish S.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans