In the spirit of the upcoming Valentine’s Day, I figure I’ll express my love for something in Salesforce. (yeah, I know…)
Aaahhh Custom Settings, how do I love thee…let me count the ways:
- You allow me to insert admin-customizable variables in Apex code
Often, you have the need to make profile-specific, record-specific, or on/off flags in your code. In “old school” desktop programming, you could access the registry or manage an ini file for these kinds of things, but in the cloud world there is not really an obvious option anymore.
You are faced with either being eternally support-bound to the project, or training someone at the client to edit code. Using Custom Settings, you get it back! Declarative control over programmatic variables for the win!
- You allow me to create a hierarchy of settings per profile
Need different versions of the same settings for different people, processes, or users? Do you need the decision on what setting is used to be at runtime? Boom.Custom
Settings can either be in a:
- List Format – where you can create multiple instances of your settings and refer to them manually throughout your code
- Heirarchy Format – where you can create profile-specific instances of your settings
- You are accessible via the Schema! Custom Settings are rendered up just as if they were custom objects. You can create, edit, and delete them through code just as easily as you would through the UI.