web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    Blue Wang Profile Picture
    on at
    RE: D365 Events & Extensions

    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]

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: D365 Events & Extensions

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 789 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 607 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 497 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans