What is Custom Settings in Salesforce?
Updated on 18th Oct, 21 25 Views

Custom Settings in Salesforce are similar to custom objects in Salesforce.It allows users to create custom sets or custom chunks of data which creates easier access of data to users. Some particular data that you want to automatically fetch from the records can be easily done by using Custom Settings. The process is also totally different from that of creating record types and page layouts.

Check out this video on Salesforce Tutorial on YouTube:

 

What is Custom Settings in Salesforce?

Custom Settings is a way through which anyone can get easier and faster access to data. It creates custom chunks of data according to the user needs which are stored in the application cache to allow faster access in Salesforce.

Whatever data is stored in custom settings will be retrieved without any use of SOQL (Salesforce Object Query Language), hence, there is no requirement of any SQL query to be used. Custom objects are the objects which will be specifically custom-built by Salesforce Developers once necessary business information and processes aren’t fitting into the prevailing Salesforce objects.

They’ll even be spoken as economical extensions of services provided by Salesforce CRM per the wants of its clients.

Practicing for a Salesforce interview. Check out our Top 57 Salesforce Interview Questions & Answers

 

Why do we need Custom Settings?

Let’s consider an example of a library where a member comes and asks for a particular book which is one of the most read books in the library, so the librarian every time needs to go that particular row to fetch that book, making it tiresome,

Instead, he constructs a column where the most featured collection of books are kept nearer to his desk, thus, creating a kind of custom setting which makes the book to be easily accessible.

This is basically how Custom Settings works. Custom Settings allow data to be stored in the application cache, thus, allowing easier fetching of data.

 

Types of Custom Settings in Salesforce?

There are two major types of Custom Settings in Salesforce

  • List Custom Settings
  • Hierarchy Custom Settings

List Custom Settings – This is a custom setting, very similar to how custom objects work. The main purpose of this configuration is to cache the required data. This means that access to relevant data is beneficial. In addition, there will be no use of SOQL queries.

The data used in the custom configuration of the list is more or less similar between the profile and the users owned by the customer.

Also, the data can be used by all departments of the corresponding customer organization. In short, a custom list configuration provides Salesforce developers and agents with a set of reusable static data that can be accessed throughout the enterprise. This configurable setting is great for records that are commonly used in the main Salesforce application.

Hierarchy Custom Settings – Although the custom list setting has all the attributes of the custom object and all the disadvantages of the custom setting, the custom hierarchy setting has the greatest advantage for users. Using efficient hierarchical logic, these custom settings allow users to customize specific settings and link required lines to specific profiles and contacts required by the client organization.

The Hierarchy Custom Setting thoroughly searches the client organization, required configuration files, and various users for delegated tasks, and then displays the most specific and accurate meaning to the user. It is defined to display custom values ​​at the lowest level in the hierarchy.

Get 50% Hike!

Master Most in Demand Skills Now !

 

How to create Custom Settings in Salesforce?

As we know there are two different types of Custom Settings, let’s create both of them.

Example of List Custom Settings-

Let’s see how to create a list of Custom Setting with an example-

Step 1 – At first in the Quick find menu search Schema Settings and enable Manage list custom settings type. By enabling this option we can choose which custom settings we can select, otherwise, the default custom setting is the hierarchy.

Custom Settings step 1

Step 2 – Search Custom Settings from Quick Find, and a form would open up as shown below:

Custom Settings step 2

Step 3 – Let’s suppose we want to add custom settings of phone codes of countries. For example, if someone chooses India, automatically a +91 number initiates in the form, thus, it is not necessary to fetch from the database by using SOQL query in the backend. So, let’s fill the label and object name accordingly. We will choose the setting type as List.

Custom Settings step 3

Step 4 – After filling in all the details click on Save, you will be redirected to the next page where you need to add the new custom fields i.e the country codes to specific numbers

Custom Settings step 4

Step 5 – Another window opens and we need to choose the Data Type which needs to be specified according to your input. Here we will choose Text.

Custom Settings step 5

Step 6 – Now add the custom field label and length according to your input. Here we will put phone codes as field labels and put length as 10 as the length of a phone number is 10.

Custom Settings step 6

Step 7 – Our field label is created and now a summary is shown as the one in the figure

Custom Settings step 7

Step 8 – Click on save and you will be redirected back to the list page. Click on Manage to add the different fields

Custom Settings step 8

Step 9 – Add the different country codes concerning their country names-

Custom Settings step 9
Custom Settings step 9 a

Step 10 – Click on Save after adding the details and a summary is created like the one in the figure

Custom Settings step 10

Step 11 – Your List Custom Settings are now created

Become a Salesforce expert. Join our self paced course on Salesforce Admin Certification

Career Transition

Example of Salesforce Hierarchy Custom Settings-

In Hierarchy Custom Settings, there are different types of settings provided, based on a particular condition given. So, here in this example, we are taking the situation of The Great Indian Sale on Amazon.

In this, every amazon user gets a minimum of 10% discount, an Amazon Prime user gets a 20% discount and we will also provide a special discount to a particular user too. So, let’s understand how to create a Hierarchy Custom Settings with an example-

Step 1– Create a new Custom Sharing and add the Label name and Object Name accordingly. Here we will choose Hierarchy as the setting type.

Salesforce Hierarchy Custom Settings step 1

Step 2 – After clicking on Save a dialog box appears where we will click New to choose the data type. Here we choose percent as a different percentage of discounts will be provided to various users

Salesforce Hierarchy Custom Settings step 2

Confused about Salesforce? Check out our blog on “Salesforce Tutorial for Beginners

Step 3 – Add a field label and also put a length. Since the discount number is given in only two units, therefore, the length is kept as 2 here.

Salesforce Hierarchy Custom Settings step 3

Step 4 – After saving the details a dialog box appears where there are two new options. One option provides a custom setting to all the users irrespective of whether they are subscribed to Prime or any other beneficial factor. So, here we will click on New to provide the Default Organization Level Value.

Salesforce Hierarchy Custom Settings step 4

Step 5 –  After clicking on New, a dialog box appears which allows us to add the default discount percentage. Here we put 10 as the percent amount.

Salesforce Hierarchy Custom Settings step 5

Step 6 – After clicking on Save we are redirected to the list where we choose the other New option to add users with access to different discount percentages

Salesforce Hierarchy Custom Settings step 6

Step 7 – A dialog box appears which requests the Salesforce admin to add the profile and the discount percentage associated with the profile. Let’s consider Standard Platform User as the Amazon Prime User. We will add a discount percentage of 20% for the Standard Platform User.

Salesforce Hierarchy Custom Settings step 7

Step 8 – After clicking on Save, another user type is added to the custom setting. For example, if we need to provide a special discount to a particular user we can also do that by choosing User in the Location field and then add a particular user from the list and add the discount percentage accordingly.

Salesforce Hierarchy Custom Settings step 8

Step 9 – Your Hierarchy Custom Setting is now created

Salesforce Hierarchy Custom Settings step 9

This is how a custom setting is created in Salesforce according to the user’s needs.

Now, learn how to create junction object from our blog on junction object in Salesforce.

 

How to fetch Custom Setting in Salesforce?

Fetching custom settings is similar to fetching custom objects but the query script is different. Here is the difference between fetching a custom object query and fetching a custom setting query.

Query for fetching Custom Object –

LIST<sample_object_c>sobjs=[SELECT ID from Sample_object _c];

Query for fetching Custom Setting-

LIST<My_CustomSettng_c>sobjs = My_CustomSettng_c.getall().values();

Now, let’s understand how to fetch a Custom Setting in Salesforce through an example. Follow these steps-

Step 1 – Choose the developer options from the top right Settings option and enter the Developer Console.

Custom Setting in Salesforce step 1

Step 2 – As the Developer Console opens, click on the Debug option and choose Open Execute Anonymous Window to write the query

Custom Setting in Salesforce step 2

Step 3 – Go back to the Custom Settings list and choose one of the custom settings. Copy the API Name

Custom Setting in Salesforce step 3

Step 4 – Add this query in the box and click on Execute to fetch your Custom Settings

Custom Setting in Salesforce step 4
 

Advantages of Custom Settings in Salesforce

Here are some of the advantages of Custom Settings-

  • No SOQL (Salesforce Object Query Language) or any other query is required to learn prior.
  • Faster access to data as custom settings is directly saved in the application’s cache memory, thus, leading to increased performance.
  • The Hierarchical Custom Settings provide different data for different users and roles, thus, maintaining Data Integrity in the enterprise.

Become a Salesforce Administrator and App Builder

 

Disadvantages of Custom Settings in Salesforce

Here are some of the disadvantages of Custom Settings-

  • Custom Setting data cannot be deployed. You need to download the data and migrate it using a Data Loader or other migration tools.
  • Only 300 custom setting fields are allowed, anything more than that will not be accepted.
  • Custom settings count against the total number of Custom Objects in Salesforce.
  • Tabs cannot be created in Custom Settings like the Account tabs, contact tabs, etc can’t be created.

To manage all these issues in Custom Settings, we use Custom Metadata in Salesforce.

Conclusion

In this blog, we learned how Custom Settings in Salesforce works and how it is applied in real-world scenarios. We also learned the difference between List Custom Settings and Hierarchy Custom Settings. Custom Settings allows the users to provide easy and faster access to data in Salesforce.

Have any more queries regarding Salesforce Developer Jobs, Join our Salesforce Community page and get your queries answered.

Course Schedule

Name Date
Salesforce Certification 2021-10-30 2021-10-31
(Sat-Sun) Weekend batch
View Details
Salesforce Certification 2021-11-06 2021-11-07
(Sat-Sun) Weekend batch
View Details
Salesforce Certification 2021-11-13 2021-11-14
(Sat-Sun) Weekend batch
View Details

Leave a Reply

Your email address will not be published. Required fields are marked *

Looking for 50% Salary Hike ?

Speak to our course Advisor Now !

Associated Courses

Subscribe to our newsletter

Signup for our weekly newsletter to get the latest news, updates and amazing offers delivered directly in your inbox.