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 Salesforce Training video 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 Salesforce Interview Questions & Answers.
Types of Salesforce Custom Settings?
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.
Create List 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.
Step 2 – Search Custom Settings from Quick Find, and a form would open up as shown below:
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.
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 in Salesforce i.e the country codes to specific numbers
Step 5 – Another window opens and we need to choose the Field Type which needs to be specified according to your input. Here we will choose Text.
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.
Step 7 – Our field label is created and now a summary is shown as the one in the figure
Step 8 – Click on save and you will be redirected back to the list page. Click on Manage to add the different fields
Step 9 – Add the different country codes concerning their country names-
Step 10 – Click on Save after adding the details and a summary is created like the one in the figure
Step 11 – Your List Custom Settings are now created
Enroll in this Salesforce Training in Bangalore to start your journey today!
Get 100% Hike!
Master Most in Demand Skills Now !
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.
Create Hierarchy Custom Settings in Salesforce
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.
Step 2– After clicking on Save a dialog box appears where we will click New to choose the field type. Here we choose percent as a different percentage of discounts will be provided to various users
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.
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.
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.
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
Step 7– A dialog box appears that 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.
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 adding a particular user from the list and adding the discount percentage accordingly.
Step 9– Your Hierarchy Custom Setting is now created
This is how a custom setting is created in Salesforce according to the user’s needs.
Now, learn how to create junction objects from our blog on junction objects in Salesforce.
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 is 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.
Check out Intellipaat’s Salesforce Training to learn with experts.
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.
The query for fetching Custom Object –
LISTsobjs=[SELECT ID from Sample_object _c];
The query for fetching Custom Setting-
LISTsobjs = 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.
Step 2– As the Developer Console opens, click on the Debug option and choose Open Execute Anonymous Window to write the query
Step 3– Go back to the Custom Settings list and choose one of the custom settings. Copy the API Name
Step 4– Add this query in the box and click on Execute to fetch your Custom Settings
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.
Preparing for a Salesforce Admin Interview! Check out our Top Salesforce Admin Interview Questions and Answers.
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 Salesforce 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.