.ultrageek. Computers, Music, and Thoughts


Custom Settings Fun

Custom Settings are one of the great ways a developer can give admins power to update logic, settings, and the behaviour of code and really make code more flexible.

This is just a quick reference of all the cool ways you can pull those settings back out without having to use a SOQL statement.

This method loads all of the custom settings in to a list:
list<Customer_Setting_Name__c> buList =Customer_Setting_Name__c.getall().values();

This method loads a record using the name as a filter. This of course assumes you are not loading duplicate names:
Customer_Setting_Name__c aplo =Customer_Setting_Name__c.getValues(filter_string); // filter_string is just a string passed in

And finally, this method loads all of the custom settings in to a map with the name as the key:
Map<String,Customer_Setting_Name__c> buMap =Customer_Setting_Name__c.getAll();

The great thing is that these do not take a SOQL hit and admin can update these.

Some of the uses I use this for:

  • Mapping Business Unit settings for Lead Queue's, record types, groups, etc.
  • Multi-dimensional Pick lists that need to shared across objects, enabled/disabled (Global Picklists have taken the place of a lot of these), and that require additional attributes but maybe don't warrant the need for a full custom object IE security.
  • For 'quick disable' functionality for when I want to put code in production that might need to be quickly disabled


Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.