List Custom Settings
By the end of this lesson, you'll be able to:
- Explain what a list custom setting is and how it differs from a custom object
- Read a list custom setting's values in Apex without a SOQL query
- Recognize when a list custom setting fits a configuration need
Prerequisites: Module 28: "Apex Security"
What makes a custom setting different from a custom object
Warehouse_Stock__c from Module 23 is a custom object — real transactional data, queried with SOQL, subject to CRUD/field-level security (Module 28). A custom setting is a different kind of custom data structure, purpose-built for configuration: values an admin sets up once and Apex reads repeatedly, cached for fast, cheap access.
Reading a list custom setting
List<Shipping_Rate__c> allRates = Shipping_Rate__c.getAll().values();
for (Shipping_Rate__c rate : allRates) {
System.debug(rate.Name + ': R' + rate.Rate_Per_Kg__c);
}
getAll() returns every row of a list custom setting as a Map<String, Shipping_Rate__c> keyed by name — .values() (Module 16) turns that into the List used here. Critically, this is not a SOQL query — it doesn't count against the 100-query governor limit from Module 25, since custom setting data is cached.
When a list custom setting fits
A list custom setting suits static, admin-configured reference data — shipping rates per region, tax rates per country, feature-flag toggles — values that change occasionally through Setup, not through everyday business transactions. It's the wrong choice for data that changes constantly through normal business activity (that's what a real custom object is for).
Exercise
As a comment, explain why reading a list custom setting doesn't count against the SOQL governor limit.
Show hint
Think about how getAll() actually retrieves its data.
List Custom Settings Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
A list custom setting stores org-wide configuration data as reusable rows — read from cache in Apex, with none of the query-cost or CRUD/FLS considerations a real custom object carries.