Events in Microsoft Dynamics NAV (Part-2): Demo

This article show a complete demonstration about how to play with the events in Microsoft Dynamics NAV.


Hi guys,

Today I am writing continuing the article which I have posted last time, on the very hot topic which is “Events in microsoft dynamics NAV”. If you have not followed the first part you can read it here.

This article show a complete demonstration about how to play with the events in Microsoft Dynamics NAV.


Suppose our business scenario is whenever a Customer is created in Dynamics NAV we should add it in our custom table as well.  We will perform this activity by creating our custom codeunit say  50005 and then defining a method (event) say CreateCustomerInMyCustomerTableOnAfterModifyEvent  in this codeunit. This new event will be the subscriber of the event OnAfterModifyEvent in Customer Table 18.


  1. Create a MyCustomer Table. createmycustomertable
  2. Create a codeunit  say “Create My Customer”.
  3. Create a function in this code unit a name it CreateCustomerInMyCustomerTableOnAfterModifyEvent
  4. Go to the function properties and set the properties as:
    1. Event: Subscriber
    2. EventPublisherObject: Table Customer
    3. EventFunction: OnAfterModifyEvent
  5. Close the property window and save the codeunit.
  6. Now go to the Locals of your function CreateCustomerInMyCustomerTableOnAfterModifyEvent and define a variable of type record to insert new item in MyCustomer Table.subscribing-an-eventcreating-locals
  7. Now write the code in your function.create-cide MyCustomer.INIT;
    MyCustomer.”No.” := Rec.”No.”;
    MyCustomer.”Customer Name” := Rec.Name;
    MyCustomer.”Customer Email” := Rec.”E-Mail”;
  8. Compile and save the codeunit.
  9. Now go to the Windows Client and create a new customer. You will see that customer record is in your custom table too.output


Congratulations! You have created your first event based application in Dynamics NAV. If you like my post, don’t forget to share it. 🙂

To Download the Demo Files: Click Here

Author: zohaib.ahmed

I am an IT professional, a GEEK by nature who loves to get his hands dirty by experiencing new technologies in the domain of computer science. I am doing development in different domain since last 3 years. Right now, I am working as a Dynamics NAV technical consultant.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s