function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rohit kumar singh 1Rohit kumar singh 1 

custom setting use cases

When is custom setting is used or comes into picture from administration point of view.

If I have A custom setting object "Company" of Hierarchy setting type visibility is protected.Inside that i have two field Phone_Number(Phone) and Information(Text) . 
I have managed the data i.e I have created two data inside that one to Chatter free user profile and another to Custom:Sales Profile.
how to see the output and where to use this.
This is the scenarion now how and where all I can use this custom setting object.
Creating is fine but what is the use of this..?
EldonEldon
Hi Del,

In the following example, the hierarchy custom setting GamesSupport has a field called Corporate_number. The code returns the value for the profile specified with pid.
 
GamesSupport__c mhc = GamesSupport__c.getInstance(pid); 
​string mPhone = mhc.Corporate_number__c;
The example is identical if you choose to use the getValues method.

So in your case if you want to see the custom settings data assigned for chatter free user profile quer that profile id to lets say chattterId and pass it int he getinstance() like below
 
Company__c c = Company__c.getInstance(chatterId);
string ph = c.phone_number__c;

Now you will have the phone number in ph variable.

For more info refer this link which explains in detail
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_custom_settings.htm


Regards