The post How to use Custom setting in Salesforce? appeared first on Salesforce Next Gen.
]]>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:-
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<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;
}
}
7. Custom Setting in Salesforce
The post How to use Custom setting in Salesforce? appeared first on Salesforce Next Gen.
]]>