Friday, September 26, 2014

Custom settings in Salesforce

Custom settings in Salesforce


Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database.
We can create custom setting for storing data similar to custom objects in salesforce but here the data is static.
Similar to custom object, we can create fields in custom setting and after creating the fields, we can click on‘Manage’ button to add records in that custom setting. Then we can use the values in these records in our apex code, validation rules. The benefit of using custom setting instead of custom objects:

  • Data in custom setting is available in application cache, hence efficient and fast access.
  • No need to waste SOQL for fetching data from custom setting. There are some methods available in custom settings that we can use to get the data instead of SOQL.

Types of custom settings available in salesforce :

List Custom Settings:
A type of custom setting that provides a reusable set of static data that can be accessed across your organization. If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it. Data in list settings does not vary with profile or user, but is available organization-wide. Examples of list data include two-letter state abbreviations, international dialing prefixes, and catalog numbers for products. Because the data is cached, access is low-cost and efficient: you don’t have to use SOQL queries that count against your governor limits.

heirarchy 2


Hierarchy Custom Settings:
A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.

Hierarchy

In above screenshot, you can see that records in a particular custom setting can be created for particular profile or user. But this is not the case with List custom setting. Records in list custom setting are available for all users and profile in application.
Salesforce imposes certain limits on the amount of cached data and on custom settings:
  • The total amount of cached data allowed for your organization is the lesser of these two values:
  • 10 MB
  • 1 MB multiplied by the number of full-featured user licenses in your organization
For example, if your organization has three full licenses, you have 3 MB of custom setting storage. If your organization has 20 full licenses, you have 10 MB of storage.
Each Certified managed package gets its own separate limit in addition to your organization limit. For example, if your organization has two certified managed packages installed and your organization has three full licenses, each certified managed package can have 3 MB of custom setting storage, in addition to your organization’s 3 MB custom setting storage limit.

  • 300 fields per custom setting.
  • You can’t share a custom setting object or record.
  • No owner is assigned when a custom setting is created, so the owner can’t be changed.
  • Custom settings are a type of custom object. Each custom setting counts against the total number of custom objects available for your organization.








 
| ,