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
vivworldvivworld 

How Can we do a SOQL Query on a List Custom Setting?

chandra2ravichandra2ravi
select field names from customsettings API name.
ex:select id,name from customsettings__c
Amit Chaudhary 8Amit Chaudhary 8
you can simply query the custom setting record like any other custom object
 
select name from customSettingName__c

 
farukh sk hdfarukh sk hd
To use custom settings in class,
You can use the methods available.

Methods available with list custom settings are:

1)getAll(); 
2)getValues(); 

Methods available with Hierarchy custom settings are:
1)getOrgDefaults(); 
2)getInstance(); 

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

 
Suraj Tripathi 47Suraj Tripathi 47
Hi,
Greetings!

Yes, you can perform SOQL query in custom settings as you perform in the salesforce object.
For example-
You have a custom setting name School__c which having the field RollNo__c and Name.
Your query should be-
SELECT Name, RollNo__c FROM School__c WHERE Name = 'XYZ';

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi