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
Rick_93Rick_93 

Get Custom Setting in Apex Page

Hi guys,

is there a way to access to a specific custom setting for the current profile directly from my Apex page ?

Thanks in advance :)
BHinnersBHinners
Here is the description of methods for use with custom settings: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_custom_settings.htm
Amit Chaudhary 8Amit Chaudhary 8
Hi Rich,

There are two type of custom setting we have
1) List Custom Settings
2) Hierarchy Custom Settings

List Custom Settings
A type of custom setting that provides a reusable set of static data that can be accessed across your organization. If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it. Data in list settings does not vary with profile or user, but is available organization-wide. Examples of list data include two-letter state abbreviations, international dialing prefixes, and catalog numbers for products. Because the data is cached, access is low-cost and efficient: you don't have to use SOQL queries that count against your governor limits.

Hierarchy Custom Settings
A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.

The following examples illustrate how you can use custom settings:
  • A shipping application requires users to fill in the country codes for international deliveries. By creating a list setting of all country codes, users have quick access to this data without needing to query the database.
  • An application calculates and tracks compensation for its sales reps, but commission percentages are based on seniority. By creating a hierarchy setting, the administrator can associate a different commission percentage for each profile in the sales organization. Within the application, one formula field can then be used to correctly calculate compensation for all users; the personalized setting at the profile level inserts the correct commission percentage.
  • An application displays a map of account locations, the best route to take, and traffic conditions. This information is useful for sales reps, but account executives only want to see account locations. By creating a hierarchy setting with custom checkbox fields for route and traffic, you can enable this data for just the “Sales Rep” profile.
  •  

Hierarchy Custom Setting Examples :-
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;
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_custom_settings.htm
2) http://blog.jeffdouglas.com/2010/01/07/using-list-custom-settings-in-salesforce-com/

Let us know if this will help you

Thanks,
Amit Chaudhary
Rick_93Rick_93
But there is a way to call a Custom Setting for a specific profile dircetly from the apex page ?

ex: 
 
​<apex:outputText value="{!-$myCustomSetting-}" label="Custom Setting:" />

Thanks