Activity Forums Salesforce® Discussions What is the difference between a standard and a custom controller in Salesforce Apex?

  • What is the difference between a standard and a custom controller in Salesforce Apex?

    Posted by Arun on January 21, 2020 at 2:40 pm

    What is the difference between a standard and a custom controller in Salesforce Apex?

    Manish replied 4 years, 3 months ago 4 Members · 3 Replies
  • 3 Replies
  • Anuj

    Member
    January 21, 2020 at 2:47 pm

    Hi Arun,

    Standard Controller:-

    Standard controller in apex, inherits all the standard object properties and standard button functionality directly.
    It contain the same functionality and logic that are used for standard Salesforce pages we can not modify it.

    Custom Controller:-

    It is an Apex class that implements all of the logic for a page with Custom functionality.
    Custom Controllers are associated with Visualforce pages through the controller attribute.
    Custom controller defines its own functionality whatever the User wants and we can modify it according to requirements.

  • Aditya

    Member
    January 21, 2020 at 3:24 pm

    Standard Controller:

    Standard controller in apex, inherits all the standard object properties and standard button functionality directly.
    It contain the same functionality and logic that are used for standard Salesforce pages.
    It Can be used with standard objects and custom objects.
    It can be extended to implement custom functionality using extensions keyword.
    It provides a save method to allow you to persist changes.
    You’d use this when you have a singe object to manipulate.

    Custom Controller:

    It is an Apex class that implements all of the logic for a page without leveraging a standard controller.
    Custom Controllers are associated with Visualforce pages through the controller attribute.
    Custom controller defines its own functionality.
    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.

  • Manish

    Member
    January 21, 2020 at 5:03 pm

    Hi Arun

    Standard controller : it is to used to use the standard functionality provided by salesforce on Visualforce page.

    <apex:page standardController="Account">

    </apex:page>

    Custom Controller:  when we want to add our own logic to design the page with apex then we use custom controller.

    <apex:page Controller="MyCustomAccount">

    </apex:page>

    Note: We can both standard and custom controller to use the fuctionality bu sing extensions.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos