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

D365 Events & Extensions

(0) ShareShare
ReportReport
Posted on by 115

Hi,

I am working on D365 FO. I am bit confusing on Extensions and Event handlers.

When we can go for Extensions and When we can go for Event handlers..? and what is the difference between these two.

--

Regards

ARK

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Extension is a much broader concept. You can use extensions to enhance tables, forms, queries, classes and so on.

    In classes, you can use class augmentation / Chain of Command to create an enhanced version of the base class. The syntax for this is to use "extensionOf" attribute in the class. Using class augmentation / Chain of Command is much more powerful than event handlers, since you have access to all public and protected members of the class. Also with CoC you can add your code to run in the same transaction scope than the method that you hook into.

    Event handlers can only be used on public methods, or with predefined events. You can't run event handler in the same transaction scope than the original method.

    In general you should use Chain of Command when possible. Sometimes it's not possible and you need to use event handlers. In most scenarios both are possible, but CoC is easier to read and more powerful so why not use it.

    Here's MS documentation about CoC: docs.microsoft.com/.../method-wrapping-coc

    There are many discussions about this topic, which you can find by searching the web for "dynamics 365 operations chain of command event handler", here are some:

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

    community.dynamics.com/.../can-i-use-event-handlers-pre-or-post-instead-of-coc

  • Verified answer
    Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Toayyappa,

    In addition, one thing is that you need to be aware that using event handlers in extension classes can bother you.
    You can read this blog:

    [View:https://daxmusings.codecrib.com/2018/06/accidental-code-extensions.html:750:50]

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
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans