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

Announcements

News and Announcements icon
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 56

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
    239,670 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
    56 on at

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

  • Martin Dráb Profile Picture
    239,670 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,843 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
    56 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,843 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
    56 on at

    Thanks Girish

  • Martin Dráb Profile Picture
    239,670 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 635 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 595 Super User 2026 Season 1

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 557

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans