custom setting

How to Use Custom Settings in Salesforce | The Developer Guide

Custom Setting:

Custom settings are like custom objects. Application engineers can make custom arrangements of information and partner custom information for an association, profile, or explicit client.

All custom settings facts are exposed inside the utility cache, which permits efficient access without the value of repeated queries to the database. Formula fields, validation guidelines, flows, Apex, and SOAP API can then use this information. Custom setting are stored in chache memory means easy to Access.

There is no Need of SOQL to retrieve the data. With the help of Custom settings can minimise the use of SOQL .

dont miss out iconDon't forget to check out: Top Salesforce Lightning Components to Improve Functionality

Different types of Custom Settings

There are two types of Custom Settings:

1. List Custom Settings
2. Hierarchy Custom Settings

List Custom Settings

Same data for every user in organization. Data in list settings does not vary profile to or user to user. It is constant for every user.

Example:– A simple example is to store pine code with respect to Complete District name.

Hierarchy Custom Settings</h3

This Types a custom setting that makes use of an integrated hierarchical logic that lets you customise settings for precise profiles or customers. Set data not only for org level. it means you set data profile level and user level. Hierarchy Custom Setting Allows  different databases for different profiles and users.

Examples:- A company offers different types of discount( 20,30,50, discount) to different types( A,B,C  category) of Customers. Hierarchy Custom Setting can handle this Scenario.

Advantage of  Custom Settings:

> No query required in custom Settings

> Fast access of Data increases the performance of organizations.

>Reduced the use of HardCoded Id uses

Disadvantages of Custom Settings:

>Custom Settings data cannot be deployed.

> only 300 fields allowed in custom setting

>Tab cannot be created in custom settings

> lookup relationship and picklist fields cannot be used in Custom Setting.

dont miss out iconCheck out another amazing blog by Ayush here: Formula Field and Validation Rule in Salesforce

Methods for Accessing a List Custom Setting:

1. Using getAll(),

2. Using getValues(Custom_Setting_Name),
Eg:- public CustomSetting__c getValues(String dataSetName)

3. Using getInstance(dataSetName)
Eg:--CustomSettingName__c CS = CustomSettingName__c.getValues(dataSetName );

Methods for Accessing a Hierarchy Custom Setting:

1.Using getOrgDefaults ()
Eg: CustomSettingName__c Cs = CustomSettingName__c.getOrgDefaults();

2. Using getInstance ()
Eg. CustomSettingName__c Cs = CustomSettingName__c.getInstance(Profile_ID);

Steps for create Custom Settings:

Go to Setup > Quick find Box > Enter Custom Settings >

Click New > For Label Enter “your Choice ” and for Object Enter “Your choice” and Select Types of Custom setting 1. List, 2. Hierarchy. Then Save.


Reference: Webkul, salesforce.stackexchange

Popular Salesforce Blogs