October 20, 2014

Custom Settings in Salesforce


Description:

Custom settings to create and manage custom data at the organization, profile, and user levels. Custom settings data is stored in the application cache. It can access efficiently, without the cost of repeated queries. Custom settings data can be used by formula fields, Visualforce, Apex, and the Force.com Web Services API.

There are two types of custom settings:

List Custom Settings:

It have user-independent values, retrieved under multiple names.
  •          Setting for development environment.
  •          Setting for volume testing environment.
  •          Setting for production environment.
List custom settings need to be accessed using a controller if you want to availiable them on a page, for example return ListSetting__c.getInstance('Test1').Field__c;

Note: It can be stores static data that can be used in apex code.

Hierarchy Custom Settings:

It can be configured at varying user specificity levels under a single name;
  •          Setting per user.
  •          Setting per profile.
  •          Setting for whole org.
Hierarchy custom settings are easily retrieved in Visualforce: {!$Setup.Student__c.Field__c} and will be resolved according to the current user context.

Note: It Can be stores data that may change depending on user, profile or org wide default.

How to configure Custom Setting in salesforce:

Step1:Goto---->Setup---->Custom Setting--->Click on New Button---->To Create Custom Fields

    
                      



Step 2: Click New Button enter All Information

     
                       



Step 3:Click Manage Button to see all records particular object(StudentData__c) in custom setting.

                       


Example:

https://c.ap1.visual.force.com/apex/CustomSettingEx

Visualforce page name: CustomSettingEx

     
                   


Apex Class: CustomSettingMethod


                     



Output:

                      


Note:
Custom settings have their own instance methods to allow easy access.
It looks like

                        


Limits in Custom Settings:

1. The total amount of cached data allowed for your organization :
    i.  1 MB multiplied by the number of full-featured user licenses in your organization.
    ii. 10MB.
2. 300 fields per custom setting.
3. You can’t share a custom setting object or record.
4. Custom settings are a type of custom object.
5.Each custom setting counts against the total number of custom objects available for your organization.

Interview Question's on this topic:
  • What is Custom settings?
  • How Many Types of Custom Settings?
  • What are instance methods in custom settings?



No comments:

Post a Comment