Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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.
  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.

  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.

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.

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

On this 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.

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 fetchDocMapFromCustomSetting(String profileName){

map mcs = new map();

list 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

The post How to use Custom setting in Salesforce? appeared first on SalesforceNextGen.



This post first appeared on Salesforce Next Gen, please read the originial post: here

Share the post

How to use Custom setting in Salesforce?

×

Subscribe to Salesforce Next Gen

Get updates delivered right to your inbox!

Thank you for your subscription

×