Skip to main content

MSDYN365BC - Futuristic CAL Development - What If No Trigger Event Found?

Hi Readers,

Last article we Understand what are Trigger Events.

As promised in this post we will understand if you are doing development in Pre-NAV 2016 Database.

If you are new to this series then Please Refer Table of Index.

With this article, We will understand about HOOKS and Use Hooks for development.

This will help Developers to develop with keeping in mind about the future and all code can be easily transported to the future when your customer plan to Upgrade. Let's discuss that in details.



What is Hook?
In programming, a hook is a place and usually an interface provided in a packaged code that allows a programmer to insert customized programming. For example, a programmer might want to provide code that analyzed how often a particular logic path was taken within a program.

What we Need?
We should know which Trigger (Tables & Pages) Events are supported in the Future. With that in mind, we will be writing code in the right approach and futuristic way.

Why we need that?
If you think that what we discussed in this article will be an overhead for the future you should not do that. I think there are advantage and disadvantages of using HOOKS for Table and Page Trigger Events but you as Developer can decide what suits you best.

If you use HOOKS for Page and Table Trigger Events then additional work will be removing those HOOKS and mapping it the right event. If you don't use HOOKS you will have to write all custom code outside during upgrade to new Version.

Why use Hook - Why I Suggest?
Yes, there will be an overhead in future to update HOOKS to Event Subscribers but below are benefits that I think will happen if you use HOOKS for Pre-NAV 2016 Database -

  • If you use HOOKS you will make sure that your right code in either OnBefore and OnAfter.
  • You will make sure that you will never write code in the middle of Table field, Table Trigger, Page Field and Page Triggers.
  • You will use HOOKS with and place all HOOK Code in multiple codeunit (related to 1 Functionality) which will help in future to segregate Extensions.
  • Using HOOKS will save cost and time in the future when you plan to Detangle the customizations in logical Extension.


Hook Example - 
Consider the same example but our customer is using 2009 (which they should not use now 😃).

We want to check and show an Error Message if Expense code selected by a user in G/L Account in Blocked.

What would we do as a current developer?



What is the Futuristic Way?

Let's Create a New Codeunit which will store all Hooks for this customization, as shown below.
Add a new function which is similar to Publisher in the future.
Add parameters as available in Future Publisher.
Add Custom Code that we want to Execute in Base Objects.


Now as its Pre-NAV2016 so we will have to add one line of code to invoke the code in Hook Codeunit as shown below.



This will become a Boon for you in the future.

I hope you would have got the Idea about HOOKS and how to use them.

If you have any question, please add that as the comment to the article.

Next article, we will continue with our customer requirements.

Stay Tuned for More!!

Regards,
Saurav Dhyani
www.sauravdhyani.com

Comments

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searchi...

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.