0

I want to access all the fields of a custom setting via soql? any ideas how to do it.

  • 2
    Have you looked at Custom Settings Methods ? are you sure, that you need to make a SOQL ? – Oleksandr Berehovskyi Aug 23 '18 at 5:14
  • There should be no need to query. What are you trying to accomplish that getAll would not work? – Eric Aug 23 '18 at 5:50
3

As mentioned in comments take a look at Custom Settings Methods. You might actually not need to perform a SOQL query. E.g.

// Example for get a single List custom setting
MyListCustomSetting__c listCS = MyListCustomSetting__c.getInstance(customSettingsName);

// Example for get a list of all List custom setting records
List<MyListCustomSetting__c> listCSlist = MyListCustomSetting__c.getAll();

// Example for get a org-wide Hierarchy custom setting
MyListCustomSetting__c listCS = MyListCustomSetting__c.getOrgDefaults();

// Example for get a Hierarchy custom setting for specific user or pro
MyListCustomSetting__c listCS = MyListCustomSetting__c.getInstance(userOrProfileId);

If you still need SOQL, take a look at dynamic SOQL in combination with field describe.

  • 1
    Thanks for your answer. You could improve this by including the relevant information in the answer directly to help future visitors. This way, if the links become invalid in the future, this answer would still stand on its own. Please consider making an edit. – sfdcfox Aug 23 '18 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.