Skip to main content

Notifications

Announcements

No record found.

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

  • 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,156 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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,892 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,772 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans