• Articles
  • Tutorials
  • Interview Questions

What is Standard Controller in Salesforce?

What is Standard Controller in Salesforce?
Tutorial Playlist

In this article, we’ll learn what the term “Standard Controller” means in the context of Salesforce and its significance, applications, and advantages.

To have a better understanding of the subject, let’s look at the following topics:

Check out the Video for the Salesforce Course

What is Standard Controller in Salesforce?

The Standard Controller is a very adaptable component that alters its actions according to the objects it is handling. In that regard, it may perform a remarkable amount of work without the need for programming, making it a polymorphic component.

A standard controller could seem to be a component or class that is automatically developed at design time for freshly formed custom sObjects but pre-exists for standard sObjects.

Some people might assume they exist as classes in Apex or Java that developers are not aware of, based on some of the formal documentation (e.g. “Every standard controller contains a getter function that returns the record indicated by the id…”).

It is usually more realistic to describe a standard controller as a consistent collection of user interface and data operation instructions rather than as a component or class. The Force.com engine automatically provides it, and most common and all custom sObjects may access it at design and runtime.

Similar functionality and logic are employed in a standard controller as they are in a normal Salesforce page. For instance, if you use the default Accounts controller, pressing the Save button on the Visualforce page will have the same effect as pressing the Save button on the default Account edit page.

If a standard controller is utilized and the user does not have access to the object, a warning about insufficient privileges will be displayed on the website. You may avoid this by making an object user-accessible and presenting its components clearly.

Using a common list controller, you can even create Visualforce pages that can show or interact with a group of records. The typical standard controllers in the salesforce are List pages, related lists, and mass action pages, which deal with groups of entries in this particular field.

Interested in learning about Salesforce? Enroll in our Salesforce Training now!

Why do we use Standard Controller?

It doesn’t matter how simple or complicated the connection is between a user and their company data—it still has to be handled according to a thorough set of guidelines and regulations.

The standard controller is responsible for doing this management while maintaining a clear division between the display layer and the data model.

The Standard Controller’s responsibility is to direct data and user-initiated action choices from the View to the Model. In response to the outcomes of each specific activity, controllers must respond appropriately by rerouting navigation.

The following are duties of a standard controller that are as follows:

  • Handling Data

The page, list, dialog, or form are all referred to as views and are all provided with data by standard controllers. While it is the responsibility of the view to govern how its data is presented, the controller collects data from the view when it is inputted or modified by a user and sends it to the data model for processing.

  • Controlling Actions

Standard controllers react to commands sent by users or programs that start with a view. These instructions, referred to as Actions, may be used to handle the information obtained from the view or only to react to a navigation link.

  • Monitoring Navigation

Standard controllers guide the user to any specified view connected to an action. On the basis of the precise results of various activities and data processes, they also manage redirection to the following views.

Now is the ideal moment to understand how Standard Controllers operate so that you can get solutions to the query of how to utilize Standard Controllers in Salesforce.

Check out our tutorial on Salesforce Tutorial.

Salesforce Master Course

Features of Standard Controller

As you try to comprehend what Standard Controller is, it is important that you be familiar with all of its various capabilities. Let’s take a quick look at these features now:

Features of Standard Controller in Salesforce
  • Using a Standard Controller to access data

Every Standard Controller has a getter method that returns the record that is referenced in the page URL by the “name” query string parameter.

With the use of the syntax(!object) syntax, this function enables the associated page markup to refer to the fields of the connection record’s circumstance by writing the object connected to the Controller in lowercase.

  • Standard Controller Actions

The following are the typical controller actions:

  • Save: The save action returns to the initial page when this action is finished.
  • Quicksave: By inserting a new record and updating an existing record, this operation avoids sending visitors back to the home page.
  • Update: Users can edit the page for the available record using this action. The edit action brings the user back to the page after this activity is finished.
  • List: It provides a reference object for the standard List page.
  • Styling pages with the default controller

Select the item that appears to be chosen for styling the pages with the help of the default controller.

  • Validation Guidelines and Standard Controllers

An error can be shown on the Visualforce page if a user enters data on a Visualforce page that accesses a standard controller and that data causes a validation rule fault.

The <apex: pagemessage> or <apex:message> method beneath the <apex:page> will be used to display the error if the validation rule’s error location is at the top of the page.

  • Monitoring the object’s accessibility

To avoid this error, you should ensure that your components will only function if a user has access to the object associated with the Controller.

If a person does not have the necessary rights to see the object, the visual force page that uses a controller will make that object unapproachable.

You may track an object’s availability using the statement in a manner similar to this:

{!object_Type. Object_name. available}

Want to ace the Salesforce hiring process? Intellipaat’s Top Salesforce Interview Questions are meant only for you!

Get 100% Hike!

Master Most in Demand Skills Now !

How to use Standard Controllers in Visualforce pages?

The “StandardController” element of the <apex: page> tag is used to provide a standard controller in Visualforce pages. Since the “standard controller” technique is being used in the visual force pages, we won’t be able to use the controller property.

Let’s see how to use Standard Controllers in Salesforce pages that use the Standard controllers and recognize their value:

  • Enter your username and password to log into your account at Salesforce.com.
  • Enter the URL with the apex/visualforce page name shown below:
  • A “visualforce error” happens if there isn’t a visualforce page with that name.
  • By clicking the “Construct Visualforce page” option, we can create the visualforce page.

Summing up

Although it is commonly acknowledged that standard controllers in Salesforce govern views, data, and actions, there is frequently a misunderstanding as to what precisely a standard controller is. We hope this blog clears all your doubts regarding this topic as we tried to cover all aspects regarding Standard Controller in Salesforce.

Come to Intellipaat’s Salesforce Community if you have more queries on Salesforce!

Course Schedule

Name Date Details
Salesforce Certification 01 Jun 2024(Sat-Sun) Weekend Batch
View Details
Salesforce Certification 08 Jun 2024(Sat-Sun) Weekend Batch
View Details
Salesforce Certification 15 Jun 2024(Sat-Sun) Weekend Batch
View Details