function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion


What is the use of ControllerExtension in salesforce?

Instead of using customcontroller why we use Controllerextension?


Any explanations........







A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.


A controller extension is an Apexclass that extends the functionality of a standard or custom controller.
When we Use controller extensions:
  • You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
  • You want to add new actions.
  • You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.
Ayub HeartForceAyub HeartForce

when u want to use standard controller (SObject) and there is also requirement to use one more apex controller then use

Controllerextension rather than controller else use Only Controller.


standard controller (SObject)+Controllerextension.