Salesforce Custom Settings

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9



Unlike custom objects which have records based on them, custom settings let you utilize custom data sets across your org, or distinguish particular users or profiles based on custom criteria. This means, for example, that admins can edit hierarchy custom settings to deactivate Workflow / Validation Rules for single users or profiles, without having to switch them off for the whole org (see the Using Hierarchy Custom Settings To Disable Workflow / Validation Rules example above).

Validation rules commonly need to be disabled temporarily when:

  • Code is updating old records, which were last edited before a validation rule was activated & therefore don't meet the newer rule's criteria.
  • Code is inserting new records without the values required by a validation rule's criteria.

Workflow rules commonly need to be disabled temporarily when:

  • They would trigger an Email Alert or Field Update which would overwrite or interfere the changes you are making to the record.

Use of a custom setting grants admins some declarative control over code so one of the many use cases is that when utilized, they can make it unnecessary to deploy code in order to disable triggers (see the Using Hierarchy Custom Settings To Disable Apex Code example above).

A key benefit for developers is that custom setting's data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, flows, Apex, and the SOAP API - see the Salesforce documentation.

The limits & considerations for custom settings are documented here.

List Custom Settings

It is possible to create List Custom Settings too, common use cases include storing two-letter state abbreviations, international dialing prefixes, and catalog numbers for products. However Salesforce is now promoting the use Custom Metadata Types, instead of List Custom Settings.

When you go to create a new Custom Setting, the following message will be displayed

Tip: Use Custom Metadata Types for App Configuration
If you're thinking of using list custom settings, consider using custom metadata types instead. Unlike list custom settings, you can migrate the records of custom metadata types using using packages or Metadata API tools.

Custom Metadata Types have additional benefits vs List Custom Settings as described in this answer. And according to the lead developer of CMDs "There’s a lot more planned for custom metadata types than custom settings on steroids."

Got any Salesforce Question?