Events in Microsoft Dynamics NAV


The agenda of this post is as follow:

  • Introduction to events
  • Type of events
  • Publisher and Subscriber
  • Publish and Subscribe to an event

So if you already know the stuff mentioned above, you can find some more advanced topics at my blog or at internet.

Introduction to events:

“Events enables the developers to change behavior and add functionality without explicitly changing the source code”. 

Events is a modern programming style(like hook pattern) inspired and motivated by .Net events. You can use events to design the application to react to specific actions or behavior that occur. Events enable you to separate customized functionality from the application business logic.  You can write Microsoft Dynamics NAV solutions by interfering with and rewriting much less of the base application code which eventually help you in upgrading your application.

Types of events:

There are two Categories of events as defined below:

  1. Event raised by C/AL code
    • Business Events
      If the event is business event then it means it defines a formal contract that carries an implicit promise not to change(or absolute minimum change) in future releases. This type of event is expected to published by solution ISVs, including Microsoft, but Microsoft does not even release a single business event.
    • Integration Events
      These are much similar to the Business events but does not carries an implicit promise not to change in future releases, so it means that changes can be done in future which help the developers to integrate Microsoft Dynamics NAV with other systems without having to perform traditional code modifications.
    • Global Events
      This type of events are raised by Codeunit 1- Application Management. These events are like OnAfterCompanyOpenOnAfterFindPrinterOnAfterOnDatabaseInsert. Thes events are defined as integration events by local functions in codeunit 1.
  2. Event raised by plateform
    • Database Trigger Events
      This type of events are automatically raised when any of the Create, Read, Update(rename), Delete or Validate operation is performed on table. For each database operation, there is a “before” and “after” trigger event with a fixed signature like OnBeforeDeleteEvent,OnAfterDeleteEvent,OnBeforeRenameEvent,OnAfterRenameEventetc
    • Page Trigger Events
      These are the events which are raised by the syetem if a certain function is performed on page object. The page events are closely associated to the standard page triggers.

Publisher and Subscriber:

  • Publisher
    A publisher exposes hook-point in code or processes that other partners or sub-systems can leverage.ISVs and MSFT are typical providers of  published events(not necessarily). The published event is raised implicitly by NAV runtime or explicitly through function call.
  • Subscriber
    A subscriber handeles or subscribe to the raised event. The event handler(subscriber) is automatically called by the NAV runtime.

The object which publishes the event(s) maintains a list of its subscribers, and notifies them automatically of any state changes. This is done by calling on a subscriber method. Subscriber methods don’t need to be in the same object and this fact enables integration developers to build decoupled systems.

  • Design Considerations:
    • Published event does not have a return value.
    • If a published event does not have any subscriber, there is no performance overhead.
    • One published event can have many subscribers.
    • The same event can be raised from multiple placing.
    • No control over execution order so the order of event handles being called in non- deterministic.
    • In case of an error for a subscriber, the subscriber will be ignored.

Publish and Subscribe to event(s):

Implementation Steps:

Following are the major steps for implementing an event:

  1. Publishing
  2. Raising
  3. Subscribing

Event Subscription:

The information about all the subscribers to events in an application can be view from Event Subscriptions page. You can open this page by following of the two method:

  1. Directly from the development environment.
    Go to Tools menu, choose Debugger, and then Event Subscriptions.

    Events Subscription

    Events Subscription

  2. The Session List page in the Microsoft Dynamics NAV client.
    1. Start the Microsoft Dynamics NAV client.
    2. In the Search box, enter Sessions, and then choose the related link.
    3. On the Home tab, in the Events group, choose Subscriptions.
Event Table

Event Table

This information is stored in the Table (2000000140) and represented by the page 9510 to type list.

To know more about Event subscription visit MSDN.


  • Valid Microsoft Dynamics NAV Developer Licence.

For more details visit: Getting started with events in Microsof