Monday 18 December 2017

Technique to use Pre-Event Handler functionality for Protected Method in AX7 / D365

During my development I have to run a block of code before calling of method in a class. So when I tried to create a Pre-Event handler of the method it throws an error because of Protected access modifier of the method. 

So what I have done to achieve this is that I have created an extension of a class and copied the protected method and defined my code block after that, then I have simply called the base method by using next keyword. By doing this I have given my own Pre-Event handler implementation without using any event handler as shown in below images.






2 comments:

  1. Hi
    I am facing same issue, to give color to label in whsworkexecuteform.xpp class where i want to get posteventhandler of createlabel() method which is protected.
    How can i do this in my scenario.

    Thanks
    Priya

    ReplyDelete
  2. Hi priya,

    createlabel() is a hookable method. You can follow above blog this will help you. All you need to create a extension class of WhsWorkExecuteForm and in your extended class give implementation of this method. Or if you are facing any specific issue then please comment with screenshot if possible.

    Thanks,
    Tabsheer

    ReplyDelete

How to Resolve DVT Script Issues When Applying Quality Updates in LCS for D365FO

Recently, while applying Quality updates 39, I encountered an error stating "DVT script for service mode: AOSService on machine." ...