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 :
Small and medium business | Business Central, N...
Answered

EventSubscribers vs Triggers

(0) ShareShare
ReportReport
Posted on by

Hello everyone

I'm a dynamics 365 junior developer, starting out with learning Business Central and AL.

I'm extremely curious about EventSubscribers and Triggers and the difference between them. I'm really sorry if this is asked frequently but I wasn't able to find a proper answer for my problem.

Which is the proper way of implementing a functionality? Trough the trigger or trough an EventSubscriber? Why?

Should I usually use a trigger and where I can't implement something trough triggers should I use an EventSubscriber? Should I always use EventSubscribers?

Below I have an example where I use a the OnBeforeInsertEvent trigger in an tableExtension and an EventSubscriber in a codeunit, for the same thing.

-------------------------------------------------------------------------------------------------------------------------

codeunit 50301 VendorTriggerExt
{
    [EventSubscriber(ObjectType::TableDATABASE::Vendor,'OnBeforeInsertEvent''', true, true)]
    procedure printMessage()
    begin
        Message('Hello!');
    end;
}
-----------------------------------------------------------------------------------------------------------------------
tableextension 50302 VendorExt extends Vendor
{

    trigger OnBeforeInsert()
    begin
        Message('hello!');
    end;
}
----------------------------------------------------------------------------------------------------------------------------
Thank you for your time! I really want to learn good practices for using this technology. :D
I have the same question (0)
  • Verified answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    If it is a custom table then you can use either of them, but if it is a standard table then you need to use EventSubscribers the whole point is to avoid modifying the standard objects that way upgrades are easy

  • Suggested answer
    JAngle Profile Picture
    150 on at

    Suresh has summed it up well. The other thing to note is that MS have added a lot of events (since their inception) and will add more event subscribers. Which in itself shows how we should develop where possible.

  • Community Member Profile Picture
    on at

    I see, I really appreciate your response.

    I do want to understand this subject a bit better, sorry if I bother you.

    Why do we need to avoid modifying the standard objects? Why that makes developing new functionalities easier?

    I will stick with your way of doing things as I've noticed that Business Central is created trough extensions and creating subscribers for certain events make more sense.

    Thank you very much!

  • Verified answer
    JAngle Profile Picture
    150 on at

    If you’re using BC in the cloud then you cannot modify the standard objects directly. On premise has some capability there. Extending fits into the model Microsoft themselves use for discreet apps. Extending means upgrades can take place as only your development is dependent. In the past it was more of a challenge to upgrade databases as Microsoft were dependent on users developments (sort of)

  • Community Member Profile Picture
    on at

    I strongly associate this with the Dependency Inversion Principle but I understand now.

    You guys are awesome, I appreciate the help and your time!

    Hope you have a great day :D

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,870 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,138 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 915 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans