0

5.4

mins

left

custom settings

What Are The Types of Custom Setting In Salesforce

In Salesforce, Custom settings are alike to custom objects. By reading this line we think about that, if both are similar then why do we need custom settings?

We all know that if we want to store data in Salesforce the best way to store data is by creating custom objects. But in this, several users might not have proper access to those objects. That’s why Salesforce provides us custom settings because in this we have organization-wide access.

Don't miss to check out: Things to Consider Before Deactivating a Salesforce Trigger.

A custom setting is stored in the application cache, which enables efficient access without the cost of multiple repeated queries to the database. So we can avoid governor limits by using this. When we need data we query from object and display, if we query multiple times there is a chance of hitting the governing limit. So to avoid governing limits we use a custom setting. It allows us to store a set of data and access it without querying it from the apex. 

Type of custom settings available in Salesforce : 

Hierarchy Custom Settings: It uses a built-in hierarchical logic that allows you to customize settings for specific profiles or users and this logic evaluates the organization, profile, and user settings for the current user and returns the exact or lowest value in hierarchical rank. Only this setting is available in Workflow Rules and Validation Rules.  This setting is easily fetched in Visualforce: {!$Setup.Setting__c.Field__c}.

List Custom Settings: It is very similar to the way custom objects work. It provides a set of static data that can be accessed across your organization. If you want to avoid governor limits, put that data in a list custom setting. And in list custom settings, we can access that data without writing SOQL. Data present in the list settings does not vary with profile or user, because it’s available in organization-wide. It needs to be accessed using a controller.

If you want to create a list custom settings first you have to enable the list settings. Follow the below steps to enable the list custom settings.

Go to SetUp → Enter Schema Setting in Quick Find box → Enable Manage List Custom Setting Type.

Custom objects

By enabling this option, we will have permission to create a list custom settings type.

Create a Custom setting: 

Go to SetUp → Enter Custom Setting in Quick Find box →  Select Custom Settings → Click New → Enter all the required information (Label, Object Name, Setting Type, Visibility) → Click Save.

  • Label: Name displayed in the custom settings.
  • Object Name: It is used to access the custom setting in code.
  • Setting Type: List / Hierarchy.
  • Visibility: Public or, Protected. If you want to create a managed package and want to hide the custom setting. Only those people who have the app installed can access it. Then you will select protected otherwise select public.

custom settings

Add a custom field in this , Open your custom setting → Click New in Custom fields → Create a field.

types of custom settings

Import data in Custom Settings from CSV file:

If you want to upload the data/record from the CSV file in custom settings. There are various methods to import data but here i want to import data with the help of Import Data Wizard. Follow these steps to import data from import data wizard.

Check out another amazing blog by Shweta here: Salesforce Lookup Relationship and Salesforce Master-Detail Relationship: An Overview

Go to SetUp → Enter Data Import Wizard in Quick Find Box → Click Lunch Wizard 

1.) Choose Data: (Import your Data into Salesforce)

  • What kind of data are you importing? :- Select Custom Object → Select Custom setting name (testCustom)
  • What do you want to do? :- Select Add New Records → Fill the required information
  • Where is your data located? :- Upload your file

Data Import Wizard

After this, Click Next.

2.) Edit Mapping: (Similar to custom object)

Edit Mapping

Click Next.

3.) Start Import : 

After successfully imported data from the CSV file. 

When the data is uploaded successfully, We will open the custom settings again.

Go to SetUp → Enter Custom Setting in Quick Find box → Select Custom Settings → Open your custom setting → Click Manage.

After clicking on manage we can see all the imported data.

Related Articles

Responses