Custom Settings in Salesforce – Part 1

By | December 30, 2015

Salesforce introduced a feature Custom Settings in its Winter’10 release which allows users to store custom data sets and associate them on an org-wide, profile or user basis. Custom Settings are similar to Custom Objects. In the same way that we create fields for custom objects, we need to create our own custom settings with its fields.

Real-time, bi-directional, multi-company – Sage ERP Integration with Salesforce

When using the cache methods Custom_setting__c.getAll(), .getInstance(), and .getValues(), Salesforce uses the cached values. If you use a SOQL query (SELECT id, name FROM Custom_setting__c) to get data for a custom setting, Salesforce queries the database and uses one of your allotted queries.

We can use page layouts, record types, validation rules, triggers and workflow rules on Custom Objects. Page layouts, record types, validation rules, triggers and workflow rules cannot be used on Custom Settings.

Difference between custom settings and custom objects –

Custom Objects

  1. All custom field types supported.
  2. Records are updated by users.
  3. Stored in database.
  4. Requires lookup or Master-Detail relationship to reference from another object.
  5. Counts against cross object reference limit when used in formula.
  6. We can use page layouts, record types, validation rules, triggers and workflow rules on custom objects.

Custom Settings

  1. No relationship calculated, Picklist or long/rich text fields supported.
  2. Records are updated by Admin/Developer.
  3. Cached in Memory (Limit 2MB).
  4. No relationship fields required.
  5. Not a Cross Object reference.
  6. No Page layouts, record types, validation rules, triggers and workflow rules can be used on Custom Settings.

Use of Custom Settings –

  1. No governor limit feature.
  2. The data is stored in the cache, it is very fast and efficient.
  3. You have to use the Custom Setting’s GET methods, not SOQL to query for data.
  4. Create and manage data at different levels like organization, profile and user levels.
  5. Access dictionary tables without querying.
  6. Doesn’t require hard coding of user or profile Id.
  7. Saves Time.
  8. Reduces the number of places you need to make changes.

There are two types of Custom Setting: List and HierarchyCustom Setting 1

1. List:
– List of data like custom object.
– Accessible only through code.
– Good for lists of reference data used in code.

2. Hierarchy:
– Defined globally (for organisation) by profile, by user.
– Accessible through code, formula, Validation Rules, Apex, and the Web Services API.
– Good for data that may differ based on user or profiles.
– Good for data that needs to be accessed declaratively.

Custom Setting visibility:Custom Setting 2

1. Public
The public type Custom Setting data can be accessed by everyone who has the Profile setting “Customize Application” enabled.

2. Protected
If it is protected, then no one will be able to see the Custom Settings. It will be hidden for all the Users. Only the code written in the App can access the data. So this is normally used to store application setting values such as tokens, client IDs, client secrets, etc.

When to use custom setting?

  1. When you are using the same constant value, representing the same thing in more than one formula.
  2. Data can be entered by an admin or developer.
  3. When you need a different value based on the runtime user or their profile.

When not to use custom setting?

  1. When you are using same value but it means different things in different formulas.
  2. Data needs to be entered by end users.
  3. When you need different values based on the record owner or their profile or based on permission set.

Limits of Custom Settings in Salesforce –

  1. You are unable to share a custom setting object or record.
  2. Cached data allowed for you to store in your organization depends on your licenses –
    – 10 Mb.
    – 1 MB multiplied by the number of full-featured user licenses in your organization.
    For example: If your organization has 3 full licenses, you have 3 MB of storage.
  3. You can add up to 300 fields per custom setting.
  4. No owner is assigned when a custom setting is created, so the owner can’t be changed.
  5. Each certified managed package gets a separate limit in addition to your organization limit.
  6. Accessing an undeleted custom setting in a formula field results in an error if the user doesn’t have the “Customize Application” permission. To prevent this error, redeploy this custom setting to the organization. Alternatively, delete this custom setting, re-create it with the same name and data, and then delete and re-create all formula fields that use this setting.

Is there an impact on custom object count as it’s a managed package?
It will not affect the custom object limits provided your package has Aloha status (which requires Security Review to be passed).

In our next blog, we will see how to create and use a custom setting in Salesforce. Stay tuned.

About Us
Greytrix as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce integration with Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.

Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information, please contact us at We will be glad to assist you.

Related Posts