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). 

 

 

Summary

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. 

 

About the Author

Greg Williams, Dynamics Practice Manager

As Western Computer’s Dynamics Practice Manager, Greg Williams is responsible for aligning the company’s product and service offerings with the specific needs of its customers. Greg’s 15 years of experience with ERP implementations in the manufacturing and distribution industries allows him to identify potential risks and immediately mitigate them with creative solutions.

Leave a Comment:

* Required Field

Based on this article, you may be interested in:

10-04-2017Tim Downie

Cycle Counting in D365 for Finance and Operations Warehouse Management: Part 3

Inevitably, variances will occur in inventory value during cycle count.  That is really the whole point of the cycle count.  These variances will need to be reviewed and processed for the new values to be accounted for in the inventory…

Read More
2-27-2017Carrie Saunders

How to please your rental customers in an instant feedback world

Doing business in a world dominated by social media and self-interest, it can feel impossible to meet the demands of your rental customers who have specific needs. 

Read More
4-23-2017Jens Kristiansen

The Dynamics 365 for Operations Mobile App – 5 Steps to Building the Right Strategy

Dynamics CRM has been accessible via mobile apps for some time, but the accessibility of ERP through mobile apps has understandably been a bit slower. Now, Dynamics 365 for Operations combines these applications for a full-service solution.

Read More
2-21-2017Carrie Saunders

Federal Overtime Rules Force Rental Businesses to Prepare Regardless of Injunction to Block Enforcement

By now, it is likely that you have heard that the US Department of Labor passed a rule that proposed to make millions of workers subject to overtime pay last year. The rule, which was to be in force as of Dec 1, 2016, states that employees earning a…

Read More