Friday, September 2, 2011

Custom Settings in salesforce apex

Hello folks..
We have some interesting here......

Some times we need to configure some custom objects which are apart from any relationship. Suppose we need to configure a object Name System Configuration where we are putting  some values . Dynamic values mean we can change these values based on our requirement.

Now while development we are setting the criteria based on these values.

Lets say we a object Name System_Configuration in which we have two date type field.
Start_Date
End_Date

Now we are querying the Any List of object suppose
List<Opportunity> lstOpprtunity = [select id,Name,Stage from Opportunity where CloseDate Start_Date And CloseDate <=End_Date];
So the thing is first you will have to query on the System_Configuration Object to pick the Field values Start_Date And End_Date and only then you can use these values in your filter criteria.

Now if we want escaping these kind of unnecessary queries we have the SALESFORCE CUSTOM SETTINGS .

These custom setting are just like salesforce custom object but these object have limited number of data type.
And having different type of methods which provide you convenience way to extract the data of these custom setting objects.

Why I am referring custom setting while we can do this by using salesforce custom objects. The reason is give below with the more descriptive definition of Custom setting.


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 Web services API.


The best example of custom setting is given below link :
Go a head the try it your self.





Cheers.................................................



No comments:

Post a Comment