Salesforce Custom
Settings
Although Custom Setting is similar with Custom Object, but they are different and for totally different usage. Custom object used to store all data within Salesforce for any transactions, it works similar with standard object, such as: Account, Contact, Opportunity, etc and you can create custom tab for that object.
While custom setting used to store application configurations, such as: value based on each application type or user. You cannot put custom setting data into Salesforce page layout directly as custom object. But, to access custom setting data, you need to access it from: Formula fields, Validation rules, Workflow rules, Apex class, and SOAP API.
There are 2 type of custom setting: List and Hierarchy. Formula field, Validation rule and Workflow only can access Hierarchy type custom setting, while Apex and SOAP API can access both.
Sample to access hierarchy custom setting from formula field or validation rule:
{!$Setup.CustomSettingName__c.CustomFieldName__c}
From SOAP API:
Select p.Description__c, p.Id, p.Name, p.Sign_Date__c from Position__c p
this is very similar with SOQL query to custom object.
Limitation of Custom Setting:
- Maximum total data of 10 MB, but if you have less than
10 license users, multiply 1 MB with number of users
- 300 fields per custom setting.
- Can’t share a custom setting record.
- No owner assigned for each custom setting record
- Each custom setting counts against the total number of
custom objects available for your organization.
Salesforce Custom
Settings
Although Custom Setting is similar with Custom Object, but they are different and for totally different usage. Custom object used to store all data within Salesforce for any transactions, it works similar with standard object, such as: Account, Contact, Opportunity, etc and you can create custom tab for that object.
While custom setting used to store application configurations, such as: value based on each application type or user. You cannot put custom setting data into Salesforce page layout directly as custom object. But, to access custom setting data, you need to access it from: Formula fields, Validation rules, Workflow rules, Apex class, and SOAP API.
There are 2 type of custom setting: List and Hierarchy. Formula field, Validation rule and Workflow only can access Hierarchy type custom setting, while Apex and SOAP API can access both.
Sample to access hierarchy custom setting from formula field or validation rule:
{!$Setup.CustomSettingName__c.CustomFieldName__c}
From SOAP API:
Select p.Description__c, p.Id, p.Name, p.Sign_Date__c from Position__c p
this is very similar with SOQL query to custom object.
Limitation of Custom Setting:
- Maximum total data of 10 MB, but if you have less than
10 license users, multiply 1 MB with number of users
- 300 fields per custom setting.
- Can’t share a custom setting record.
- No owner assigned for each custom setting record
- Each custom setting counts against the total number of
custom objects available for your organization.
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.
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.
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.
No comments:
Post a Comment