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, ...
Answered

Fields defined on an extension can only be private, internal or public but not protected.

(0) ShareShare
ReportReport
Posted on by 30

Hi Team,

I have created an extension class for SalesConfirmDP but got below error while rebuilding.

pastedimage1680192569099v1.png

I guess, it is happening because of final keyword declaration. If yes , than how I can resolve this issue?

Pls give me more shed on this.

thanks!

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    What problem do you see there to solve?

    Protected members are used with inheritance and you can't inherit from final classes. And there is no point in having anything else than a final class, because the extension class is instantiated by the system (in a very special way) and it would never use a child class if there was any. Therefore it's all as it should be.

  • @rp@n Profile Picture
    30 on at

    Let me know how can I solve this? What changes are required?

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

    I'm sorry, but I still don't know what you want to solve.

  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi,

    In extension classes if you declare variables globally then you must give access specifier to a variables like below.

    Public SalesConfirmDetialsTmp confirmDetailsTmp;

    Public int i;

    Public int serialization;

    Thanks,

    Girish S.

  • @rp@n Profile Picture
    30 on at

    Thanks Girish,

    Is it always public access modifier to declare in extension class?

    Pls give me more shed on this

  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    It depends on your requirement. Mostly it will be public only. If you declare it as public it will be accessible in all the methods.

    Thanks,

    Girish S.

  • @rp@n Profile Picture
    30 on at

    Thanks Girish

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

    The general recommendation is never using public instance variables. Such a design allows other classes to take dependency on implementation details of your class and it may harm maintainability and extensibility a lot.

    Instead, expose the value through a public method. Then you can change the implementation (e.g. change the value how you store the data or add extra logic, such as raising an event on value change) without changing the public interface of the class.

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 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans