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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

how to access protected level class in D365

(0) ShareShare
ReportReport
Posted on by 70

i need to access a method from standard class(that has some protection level) so i have done a extension for the class  and replicated the method that i need

and when i try to declare that extension class from another class to access the method that i want  i got error :you cannot declare the extension classes 

so i tried to declare the origin class then i got this error: class '' is not visible in this context due to the protection level of the class

how to access this class and its methods.

class name: WhsReleaseToWarehouse

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Hi ram_ind,

    could you share your code, as well as tell us what you are trying to achieve?

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    What exactly do you mean by "some protection level"?

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at

    Unfortunately there is no way. You can try to extend the calling method, or one of the methods this calls and see if you can implement it there instead. You can also request an extensibility point through LCS, which the team that owns this class will then review and potentially give you a way to do it. However, you HAVE to document what you're trying to do. Simply asking to make something public will be denied by default.

    Just a word of warning that if you try to find some hack to work around these protections, you WILL run into future compatibility problems where your production environment will stop working after updating.

  • ram_ind Profile Picture
    70 on at

    here is the code:

    this is extension class

    am trying to create the transfer order using x++ in that i need to call the releasetowarehouse process through code itself so trying  to call this class methods

    [ExtensionOf(classstr(WhsWarehouseRelease))]

    final class TestWhsWarehouseRelease_Extension

    {

       public static void main(Args _args)

       {

           Args args = new Args();

           next main(_args);

       }

    }

    and am trying to access this class method from another class

    class transferOrder

    {

    public TransferOrdercreate

    {

    TestWhsWarehouseRelease_Extension Extn = new TestWhsWarehouseRelease_Extension();//here object could not be created because TestWhsWarehouseRelease_Extension is a extension class,instantiate WhsWarehouseRelease class instead

    WhsWarehouseRelease release = new WhsWarehouseRelease();//constructor of the class is not visible in this context due to the protection level of the class

    }

    }

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    You can't instantiate your _Extension class, instead you must instantiate the standard base class. That instance will include all your extension logic.

    I don't have a system at hand but you should be able to construct that class - it must have a public constructor, otherwise nobody could construct it!

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Additionally, if you want to call the main method, you don't even need to instantiate anything since it's a static method. You can just call WhsWarehouseRelease::main(args);

    If you still have issues, please share more details. Thanks!

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    My system doesn't contain any class called WhsReleaseToWarehouse. Maybe you mean WHSReleaseToWarehouseController and you're using a wrong name in your code.

    By the way, please use Insert > Insert Code (in the rich-formatting view) to paste source code.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I do have WhsReleaseWarehouse class in my system. The construct method is indeed protected. By looking at the cross references, you will see that the standard system calls it from the main method of this class. You can also call the public static main method from your code.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans