Custom Settings in Salesforce

Learn How to Use Custom Settings in Salesforce

What is Custom Setting?

Custom Settings resemble custom items. They are by and large used to make custom arrangements of information and can be related to an association, profile or a particular client. The permeability of the custom setting can be constrained by stamping it as open or ensured. Custom Settings informational index can be utilized in Formula fields, Validation rules, streams, Apex and SOAP API

Sorts of Custom Settings

In Salesforce we have two sorts of custom settings 

  1. List Custom Settings 
  2. Hierarchy Custom Settings 

Rundown Custom Settings Hierarchy Custom Settings 

It gives a reusable arrangement of static information which can be gotten across your organization. It utilizes an implicit progressive rationale that allows you to customize settings for a particular client or a profile. 

The information in List Custom Settings is straightforwardly apparent to any client in the org. The information in Hierarchy Custom Settings actually looks at the association, profile and client settings for the current client and makes the information noticeable for them in like manner. 

The primary benefit of utilizing Custom Settings is that the information is reserved, which empowers effective access without the expense of rehashed questions to the data set. One doesn't need to utilize SOQL questions which mean something negative for the lead representative cutoff points. 

dont miss out iconDon't forget to check out: Rollup Summary for Account Hierarchy with Flow | Salesforce Developer Guide

How to Make a Custom Setting?

Quest for Custom Settings in your arrangement, and make a new Custom Setting and enter the necessary data in the fields. 

Note: If the setting type is handicapped, go to construction settings from the arrangement and empower "Oversee list custom settings type"

Presently, make Custom fields under the custom setting definition that we recently made. 

Presently Click on Manage from the custom setting definition to add information. 

Since we have made a List Custom Setting, Let's perceive how to get to it in your zenith. 

Getting to List Custom Setting Information

We can get to the information utilizing the custom settings strategies. They are all occurrence techniques, that is, they are called by and work on a particular occasion of a custom setting. 

To bring the custom fields related to a rundown setting, use the getAll() strategy. It returns a guide of informational index names and custom establishing standards.

Map var = 


Eg: Map CSN = Custom_Setting_Name.getAll(); 

To bring all the field esteems related to the predefined dataset, use getValues() strategy. This strategy can be utilized for both rundown and progressive system settings. 

CustomSettingApiName var = CustomSettingApiName.getValues(dataset_name); 

Eg: Custom_Setting_Name CSN = Custom_Setting_Name.getValues('Test');

dont miss out iconCheck out another amazing blog by Rajesh here: Using the runAs Method in Salesforce | Apex Developer Guide

Getting to Hierarchy Custom Setting information

You can correspondingly take a stab at getting to the Hierarchy Custom Setting information with the accompanying techniques

To return a custom establishing informational collection standard for the current signed in the client. Utilize the getInstance() strategy. 

CustomSettingApiName var = CustomSettingApiName.getInstance(); 

To return a custom establishing informational collection standard for a particular CustomSettingApiName.getInstance( CustomSettingApiName.getOrgDefaults(); 

Note: To make the Custom Setting information apparent in your peak test class, use "seeAllData=true".


Popular Salesforce Blogs