Custom Setting
1. Custom Setting is also like a custom object.
2. It will store the data in the application cached.
3. Any data stored to custom setting will be retrived without writing soql query.
a. It have maximum 300 fields per custom setting
b. Each custom setting count against custom object count
c. Custom setting data are exposed in the application cache
Why cache==> Because if you use the data maximum time then we can put in cache so we can access data with in a less amount of time
The total size of cached data allowed for your organisation is the lesser of these two values:
10 MB (maximum) but 1 MB multiplied by the number of full-featured user licenses in your organisation
4. There are two types of custom setting
a. List
b. Hierarchy
Why we use list== 1. Reusable set of static data
2. Set data for org level.
3. Data does not vary with profile or user, it is available organisation wide (like dialling code +91 will be same for all user for India its not change for ( user to user ) or ( profile to profile).
4. We can not use list custom setting in formula filed .
Why we use Hierarchy ==
1. Set data not only for org level ( like you can set for specific profile ,user)
2.. We can use this custom setting in Formula field.
Example== list we can use for same function (
In any mall every user will get same hospitality ( Hospitality__c )
Normal client get normal discount and special client get special discount so discount vary person to person (Discout__c )
So here Hospitality __c will come under LIST and Discount__C will come under HIERARCHY
5. How to enable custom settings :
Setup
|--->Adminster
|---> Data Management
|--->Schema Settings
|--->Enable the toggle.
6. How to create List custom setting :
Setup
|--->Build
|--->Develop
|---> Custom Settings
|---> New
Step 1: Enter Name : Capital
Step 2: Enter Label: Capital
Step 3: Choose Custom Setting Type : List
Step 4: Save
Step 5: Create Custom Fields : Salary ,Phone
Step 6: Click on Manage button and enter the data
Note : By Default every List custom setting will have name field.
7. How to fetch the data from list customsetting
a. getAll() : This method will return all the records in the custom setting in the form of Map
<!-- Map<Name,CustomSetting> -->
where name field is the key and custom setting is the value
<!--
Map<String,Capital__c> custMap=Capital__c.getAll();
System.debug(custMap.keySet());
Capital__c cap=custMap.get('Ankit');
System.debug(cap.Name);
System.debug(cap.Salary__c);
System.debug(cap.Phone__c);
-->
=========================================
Map<string,Book__c> book=Book__c.getAll();
Set<string> keys=book.keyset();
for(String s:keys){
Book__c b=book.get(s);
System.debug('name:'+b.name);
System.debug('price:'+b.price__c);
}
=================================================
8. Hierarchy Custom Settings :
a. This is used to store the different data for different profile and users
b.How to create Hierarchy custom setting :
Setup
|--->Build
|--->Develop
|---> Custom Settings
|---> New
Step 1: Enter Name : Book
Step 2: Enter Label: Book
Step 3: Choose Custom Setting Type : Hierarchy
Step 4: Save
Step 5: Create Custom Fields : Price ,Author
Step 6: Click on Manage button and enter the data
a. Default values for organization :
Author Name : Ankit
Price : 10000
Step 7: Click on New
Choose : Profile as System Admin
Author Name : Kiran
Price : 400000
Note : By Default every List custom setting will have name field.
Q: How to fetch the data
a.getInstance(userId/ProfileId) :This will return the data based on profile or user
Book__C bk=Book__c.getInstance(UserInfo.getUserId());
System.debug('Name:'+bk.AuthorName__c);
System.debug('Price:'+bk.price__c);
Use in Formula field
=======================================================================
Custom setting have currency field but it don't have picklist , text area long and external relationship filed.
1. Custom Setting is also like a custom object.
2. It will store the data in the application cached.
3. Any data stored to custom setting will be retrived without writing soql query.
a. It have maximum 300 fields per custom setting
b. Each custom setting count against custom object count
c. Custom setting data are exposed in the application cache
Why cache==> Because if you use the data maximum time then we can put in cache so we can access data with in a less amount of time
The total size of cached data allowed for your organisation is the lesser of these two values:
10 MB (maximum) but 1 MB multiplied by the number of full-featured user licenses in your organisation
4. There are two types of custom setting
a. List
b. Hierarchy
Why we use list== 1. Reusable set of static data
2. Set data for org level.
3. Data does not vary with profile or user, it is available organisation wide (like dialling code +91 will be same for all user for India its not change for ( user to user ) or ( profile to profile).
4. We can not use list custom setting in formula filed .
Why we use Hierarchy ==
1. Set data not only for org level ( like you can set for specific profile ,user)
2.. We can use this custom setting in Formula field.
Example== list we can use for same function (
In any mall every user will get same hospitality ( Hospitality__c )
Normal client get normal discount and special client get special discount so discount vary person to person (Discout__c )
So here Hospitality __c will come under LIST and Discount__C will come under HIERARCHY
5. How to enable custom settings :
Setup
|--->Adminster
|---> Data Management
|--->Schema Settings
|--->Enable the toggle.
6. How to create List custom setting :
Setup
|--->Build
|--->Develop
|---> Custom Settings
|---> New
Step 1: Enter Name : Capital
Step 2: Enter Label: Capital
Step 3: Choose Custom Setting Type : List
Step 4: Save
Step 5: Create Custom Fields : Salary ,Phone
Step 6: Click on Manage button and enter the data
Note : By Default every List custom setting will have name field.
7. How to fetch the data from list customsetting
a. getAll() : This method will return all the records in the custom setting in the form of Map
<!-- Map<Name,CustomSetting> -->
where name field is the key and custom setting is the value
<!--
Map<String,Capital__c> custMap=Capital__c.getAll();
System.debug(custMap.keySet());
Capital__c cap=custMap.get('Ankit');
System.debug(cap.Name);
System.debug(cap.Salary__c);
System.debug(cap.Phone__c);
-->
=========================================
Map<string,Book__c> book=Book__c.getAll();
Set<string> keys=book.keyset();
for(String s:keys){
Book__c b=book.get(s);
System.debug('name:'+b.name);
System.debug('price:'+b.price__c);
}
=================================================
8. Hierarchy Custom Settings :
a. This is used to store the different data for different profile and users
b.How to create Hierarchy custom setting :
Setup
|--->Build
|--->Develop
|---> Custom Settings
|---> New
Step 1: Enter Name : Book
Step 2: Enter Label: Book
Step 3: Choose Custom Setting Type : Hierarchy
Step 4: Save
Step 5: Create Custom Fields : Price ,Author
Step 6: Click on Manage button and enter the data
a. Default values for organization :
Author Name : Ankit
Price : 10000
Step 7: Click on New
Choose : Profile as System Admin
Author Name : Kiran
Price : 400000
Note : By Default every List custom setting will have name field.
Q: How to fetch the data
a.getInstance(userId/ProfileId) :This will return the data based on profile or user
Book__C bk=Book__c.getInstance(UserInfo.getUserId());
System.debug('Name:'+bk.AuthorName__c);
System.debug('Price:'+bk.price__c);
Use in Formula field
{!$Setup.CustomSettingName__c.CustomFieldName__c}
=======================================================================
Custom setting have currency field but it don't have picklist , text area long and external relationship filed.
No comments:
Post a Comment