Activity › Forums › Salesforce® Discussions › Other than SOQL and SOSL, what Is the way to get custom settings in Salesforce?
Tagged: Methods in Salesforce, Salesforce Apex Code, Salesforce Custom Settings, Salesforce Records, SOQL, SOSL
-
Other than SOQL and SOSL, what Is the way to get custom settings in Salesforce?
Posted by Anurag algoworks on September 19, 2018 at 7:45 AMOther than SOQL and SOSL, what Is the way to get custom settings in Salesforce?
Aman replied 7 years, 7 months ago 4 Members · 3 Replies -
3 Replies
-
Hi,
Other than SOQL or SOSL, Custom settings have their own set of methods to access the record.
For example:
If there is custom setting of name ISO_Country, SO_Country__c code = ISO_Country__c.getInstance(‘INDIA’);
//To return a map of data sets defined for the custom object (all records in the custom object), //you would use: Map<String,ISO_Country__c> mapCodes = ISO_Country__c.getAll();
// display the ISO code for India
System.debug(‘ISO Code: ‘+mapCodes.get(‘INDIA’).ISO_Code__c);
//Alternatively you can return the map as a list:
List<String> listCodes = ISO_Country__c.getAll().values();
Thanks
- [adinserter block='9']
-
Hi,
Adding some code snippet you can use:
Here without querying from the record we can fetch the data from server and display in viusalforce page using custom setting.
How to get the Value from custom setting
public class DemoCustomSetting
{
public List<Country__c>getData {get;set;}
public DemoCustomSetting (){
Map<String,Country__c>alldata= Country__c.getAll();getData = alldata.values();
}
}
Visualforce page
<apex:page controller=”DemoCustomSetting” sidebar=”false” >
<apex:form >
<apex:pageblock title=”Person Details”>
<apex:pageblockTable value=”{!getData }” var=”A”>
<apex:column value=”{!A.Name}”/>
<apex:column value=”{!A.State__c}”/>
<apex:column value=”{!A.City__c}”/>
<apex:column value=”{!A.Zip_code__c}”/>
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>Hope this will help
Thanks
-
Hi,
With the help of below mentioned code we can get custom settings:
If there is custom setting of name Custom_Setting, Custom_Setting_c code = Custom_Setting_c.getInstance(‘Record’);
//To return a map of data sets defined for the custom object (all records in the custom object), //you would use: Map<String,Custom_Setting_c> mapCodes = Custom_Setting_c.getAll();
Thanks
Log In to reply.