Quantcast
Wednesday , October 17 2018
Home / Apex / How To Do In Salesforce / How to use Custom setting in Salesforce?

How to use Custom setting in Salesforce?

How to use Custom setting in Salesforce?

In this post we are going to discuss how to create a custom setting and how to use the Custom setting API.

To know more about the custom setting kindly go through the post here.

To create a Custom setting follow the below steps:-

  1. Go to setup and click on the Quick find / search input box and type ‘custom settings’.
  2. Click on custom setting and then on the create custom setting page click on new button.Custom setting
  3. This will open New Custom Setting Definition page where we have to provide the custom setting with a label, Object name, its type (list/Hierarchy), visibility and its description.
  4. After filling all the information on the definition page click on save button.
  5. This will take you to the custom setting definition detail page. On this page all the system defined and the related information of the custom setting is displayed.
  6. On this page you can add new custom fields to the Custom setting similar to the Custom object, but data type of the new fields are limited as shown below.

Custom setting

 

  1. After selecting the data type remaining steps of creating the field is similar to the custom objects field creation.

Once you have created all the required fields the custom setting detail page looks something as below.

Custom setting

Once you have completed creating the custom setting, then it is the time to enter some data in the custom setting datasets. To insert the data we need to click on the manage button on the custom setting detail page, as shown below.

Custom setting

Clicking on the manage button, redirects to the dataset detail page where we can add. Delete and edit records of custom settings.

Custom setting

On tCustom settinghis page, to create a new record click on the new button and enter the value in the fields and click on save as shown below.

Custom setting

Once you have desired number of records I the custom setting. We can use the Custom setting API’s to fetch the records.

Below I have written a class which access the custom settings without making a SOQL call to database and returns a map of string and custom setting records.

public class CustomSettingCls {

 

public  map<String, IVL_Offline_document__c> fetchDocMapFromCustomSetting(String profileName){

map<String, IVL_Offline_document__c> mcs = new map<String, IVL_Offline_document__c>();

list<IVL_Offline_document__c> lcs = IVL_Offline_document__c.getall().values();

for(IVL_Offline_document__c recordCS : lcs){

if(recordCS.IVL_Profile_Name__c == profileName){

mcs.put(recordCS.Name, recordCS);

}

}

return mcs;

}

}

Also, Have a look at the below resources:

  1. Best Salesforce Interview Questions book with Apex and Visualforce concept explained

Also, Have a look at the below learning resources:

  1. SOQL (Salesforce Object Query Language)

  2. Apex Trigger Best Practices and the Trigger Framework

  3. Salesforce Interview Question and Answers Part 2

  4. Salesforce Interview Questions on Test Class

  5. Salesforce-lightning-interview-questions-2018

     6. Salesforce Interview Questions Batch Class 

 

7.  Custom Setting in Salesforce

About Sumit Datta

Sumit Datta
I am a 3x Certified Salesforce developer with overall 5 years of IT experience and 3 years of Implementation experience in Salesforce. I am here to share my knowledge and help Beginners in Salesforce to understand the concepts of Apex, Visualforce, Salesforce Lightning and Salesforce Configuration.

Check Also

MODAL Box

How to create a Modal box in Lightning Component?

How to create a Modal box in Lightning Component? In this post we are going …

Salesforce Lightning Training

How to send parameters in AuraEnabled methods in Salesforce Lightning Components?

How to send parameters in AuraEnabled methods in Salesforce Lightning Components? Passing value to and …

Salesforce Lightning Tutorials

How to use lightning accordion

How to use lightning accordion and how to dynamically add accordion section in lightning. In …

Salesforce Lightning Tutorial

How to fetch and display list of records in Lightning Component

How to fetch and display list of records in Lightning Component? In this post we …

One comment

  1. It would be great if you can post a few more use cases of custom settings

Leave a Reply

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