NAV 2017 Events – A Real World Example
With Microsoft Dynamics NAV 2017, you can use events to design the application to react to specific actions or behavior that occur, enabling you to separate customized functionality from the application business logic. Using events where customizations are usually made provides a lower cost of code modifications.
The principal is that you program events in the application to run customized behavior when they occur. In this example, we are going to develop the same customization to NAV – with and without use of Events subscriptions. The business requirement is to check to see if sales order margin is more than 20% at the time of posting.
Modifying NAV in Version 2015 and earlier
To address this requirement in older versions of NAV, a NAV developer would insert custom code into codeunit 80 to execute additional business logic (for example check if order margin is above 20%). The end result was that the business user was satisfied – until they had to pay to have a developer merge that code into the next version of NAV.
Modifying NAV in 2017
In NAV 2017, a developer would address the same business requirement without modifying codeunit 80. In the example below, you will see that Microsoft has introduced events to NAV. The event in this case is OnBeforePostSalesDoc. A NAV developer would write a custom codeunit in the customer range (50000 -99999) and then subscribe to the event in CodeUnit 80. While NAV is executing codeunit 80, that event will check the custom codeunit and execute the business logic (in this case check for 20% margin).
The difference between these two approaches is not evident to the business user. However, the new approach eliminates the need to merge code in CodeUnit 80 when moving from version 2017 to a later version. The upgrade effort will be much faster, as standard NAV code is left unmodified.
Do you have additional questions regarding events in Dynamics NAV? Comment below.
Based on this article, you may be interested in:
If you run an older version of Dynamics NAV and have been putting off an ERP upgrade—or if you run NAV 2016 and wonder if it’s worth the effort to upgrade to the new version, take a look at NAV 2017. With the latest release, Microsoft not…Read More
There is something fascinating about seeing machines do the work traditionally done by humans. This past fall at Summit (NAVUG and AXUG), our team setup a robot to demonstrate a pick and stage inventory scenario inside the Western…Read More
Microsoft Dynamics 365 and Office 365 are a powerful combination to elevate customer engagement and boost productivity, especially when most of today’s workers (and customers) are on the go. With the availability of hundreds of third-party apps…Read More
It wasn't long ago that getting on a plane was the "dead zone." Cut off from the Internet and untethered from those rapid-fire urgent emails. I felt like sitting in row 6 (or row 1 if I was lucky enough to get an upgrade) was like being…Read More