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
DJ 367DJ 367 

I want to display a hierarchy custom setting field to visualforce

Hi Everyone ,
I am new to salesforce and want to display a hierarchy custom setting field to visualforce.  Can someone help me with the code.

Thanks in advance.

Dj
Best Answer chosen by DJ 367
DJ 367DJ 367
obj__c myObj = obj__c.getValues('FieldNme');
This solved my problem. thannks.

All Answers

RbnRbn
Hi Dj,

You can only access hierarchy custom settings in formula field and validation rules. Here is the generic syntax:

{!$Setup.CustomSettingName__c.CustomFieldName__c}

for the programatic implementation, ppease go throught the below link

http://developer.force.com/cookbook/recipe/using-custom-settings-to-display-data

Let me know if it resolves your query.

Regrds,
Rabi
DJ 367DJ 367
Hi Rabindranath,
thanks for your reply but still I am facing difficulty implementing my requirement. Can I post my requirement here.

I have one hierarchy custom setting field which is number data type and i have assigned it a value - 150(for eg CusSettfield__c = 150).

I have one vf page and there is a number field. my requirement is if I enter >100 into the vf field it should display error message.

This requirment i have to meet comparing custom setting field to the vf field.
if (Vffield < customSettingField )
error(value should be more than 150)... this just I have wriiten because I am not able to perform the code.
in another way I completed this requiremnet with validation but requirment is with custom setting.

thanks in advance.
Dj


 
Glyn Anderson 3Glyn Anderson 3
Access the custom setting in Apex like this:

<pre>
Decimal customSettingField = My_Custom_Setting__c.getInstance().CusSettfield__c;
</pre>
Glyn Anderson 3Glyn Anderson 3
DJ 367, Did any of these answers solve your problem?  If so, please mark the question as "Solved".  If not, let us know.  If you solved it yourself another way, please post your solution.  Thanks!
DJ 367DJ 367
obj__c myObj = obj__c.getValues('FieldNme');
This solved my problem. thannks.
This was selected as the best answer
farukh sk hdfarukh sk hd
Let say we have custom setting called employee where we are storing employee roll number. 
Let's assume we have some employee information stored in custom setting. 
employee1     rollNo1 
employee2    rollNo2 

Syntax: 

Employee__c obj=new Employee__c.getvalues('employee1'); 
String rolNo=obj.rollNo1__c; 

For more detail visit,
https://www.sfdc-lightning.com/2018/09/custom-settings-in-salesforce.html