web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

override private method in class extension x++

(0) ShareShare
ReportReport
Posted on by 163

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 ?

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: override private method in class extension x++

    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.

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: override private method in class extension x++

    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 ?

    Screenshot-_2800_40_2900_.pngScreenshot-_2800_39_29005F00_LI.jpg

  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: override private method in class extension x++

    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.

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: override private method in class extension x++

    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

  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: override private method in class extension x++

    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.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: override private method in class extension x++

    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.

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: override private method in class extension x++

    Screenshot-_2800_38_2900_.pngI tried to make new method have same logic and change what I need , but when I debug doesn't enter class extension .why ?

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: override private method in class extension x++

    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 ?

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: override private method in class extension x++

    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.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: override private method in class extension x++

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 878 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 855 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 765

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans