Custom Settings in Salesforce

Custom Settings:-

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. This data can then be used by formula fields, validation rules, Apex, and the SOAP API.
·         custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. 

·         Formula fields only work for hierarchy custom settings; they can’t be used for list custom settings.
{!$Setup.CustomSettingName__c.CustomFieldName__c}

·         Apex can access both custom setting types.
·         When you add data to a custom setting, you must name each set of data. Then you can distinguish between the sets of data by the data set name. The following returns a map of custom settings data. The getAll method returns values for all custom fields associated with the list setting.

Map<String_dataset_name, CustomSettingName__c> mcs = CustomSettingName__c.getAll();

Samples for Hierarchy Custom Settings

The following example uses the getOrgDefaults method to return the data set values for the organization level:
CustomSettingName__c mc = CustomSettingName__c.getOrgDefaults();
The following example uses the getInstance method to return the data set values for the specified profile. The getInstance method can also be used with a user ID.

CustomSettingName__c mc = CustomSettingName__c.getInstance(Profile_ID);

Salesforce imposes these 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:
o    10 MB
o    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.

No comments:

Post a Comment