There is any way to override private method in class extension ?
I made a class extension and I want to override method but its private method , How Can I access it ?
Hi Menna, Thanks for pointing out I didn't checked that method, you need duplicate this method as well then. This is the downside of bypassing a private method, lot of standard code has to be duplicated and that's why not a recommended approach.
Hi Mohit , Thanks for your replying but I want to ask you a question , when I opened InventJournalTableJumpRefHelper class the menuItemName() method called in jumpref() method not in main method so How Can I Change it in main() method , In getmenuItemName(tableBuffer) method I want to change logic in it change returned name from it not parameter . Can you explain it ?
Hi Menna, You can create a copy of main method of InventJournalTableJumpRefHelper class and rename and replace menuItem name in getMenuItemName method's parameter.
Create extension class of InventTransRefId field in ITMOverUnderTransLine datasource in ITMOverUnderTrans form. For reference you can check below thread
community.dynamics.com/.../extension-class-of-form-datasource-field-method
Create Coc method for JumpRef and before 'next JumpRef' change ITMOverUnderDocType to any other value so it will bypass standard jumpRef code later. Copy jumpRef code in your method and replace call to Main method with your new method.
Please note that its not an ideal approach and not recommended by Microsoft as it will require to bypass standard method and creating your own methods. So, in future if MS releases any update to these objects, your customizations will impact.
Hi Mohit , My requirement is to change the menu item name that called in jump ref method , but menu item name () is a private method in InventJournalTableJumpRefHelper class so to change that I wrote a new public method in class extension and change the menuitemname () in jump ref to my new method but class extension didn't called when I debug
Hi Menna, Can you please explain the requirement and which private method you are trying to override? jumpref is a public method in InventJournalTableJumpRefHelper class.
Also you don't need to copy entire method in extension class. After 'next jumpRef' line you should add your logic and like Girish mentioned if sysmbols are loaded correctly, this method should be called.
Does the symbol loads correctly?
Place the debugger point inside the method and check.
After the symbol is loaded the debugger point becomes red and it won't show any warnings.
Thanks,
Girish S.
I tried to make new method have same logic and change what I need , but when I debug doesn't enter class extension .why ?
How to duplicate the method , I want to change some logic in private method in class .
I made a class extension , How to duplicate method ?
You can duplicate the method and call that method instead of calling standard method.
But keep in mind, in future if Microsoft release any updated on that method it won't update on your custom method.
Thanks,
Girish S.
Have you checked this thread
community.dynamics.com/.../881069
As Martin mentioned you can't extend private method, either raise extensibility request to Microsoft but high chances the request won't be approved easily as Microsoft made those methods private for reason.
FYI, we raised extensibility request few months ago, none of it is approved.
André Arnaud de Cal...
292,162
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156