You need to sign in to do that
Don't have an account?
custom settings example or scenario..?
where i can use custom settings or what can be scenario where in i need custom setting i have gone through the theory need any practical scenario,,?
You need to sign in to do that
Don't have an account?
1. I was required to assign the opportunity to certain user when the opportunity revenue value is less than certain number. So here opportunity revenue value may change any time depending on the business growth for the company so here we have to make opportunity revenue value configurable. Here you will use Custom Setting for this.
2. Recently i was required to include the record in the next run time based on last runDate time of Batch(incremental load). So here once batch finished processing then i was updating custom setting field with batch finished Date and Time. so that next time when batch run i will read this Custom setting to take last run date time to filter the record so that we can excude the already processed record.
Regards,
Pawan Kumar
There are two types of custom setting:
- List Custom Settings
- Hieriarchal Custom Settings.
To Know more,Please looke here: https://help.salesforce.com/apex/HTViewHelpDoc?id=cs_about.htmUse of Custom Settings
Hard-coding and good code are a match made in hell. RecordTypeIds are most vulnerable to this abuse, and we’re are all familiar with the frustration of finding that code that worked in environment A, suddenly stops working when it is promoted to say test. Why? Because possibly RecordTypeIds are different across the two environments.
Why hard-code when you can use Custom Setting for stuff like this ? Custom Settings are a SOQL inexpensive way of storing your configurable parameters in the safe confines of the Salesforce database, with all the conveniences of a custom object – create / edit via point and click – standard salesforce !
Under the hood Custom Settings are much like a Custom Salesforce Object, save for you cant have triggers on them. Most obvious difference, amongst others.
One of the best example of using custom setting in code is here:
http://www.sfdc99.com/2014/03/02/change-your-code-on-the-fly-using-custom-settings/
Below is real time scenario for custom settings.
- Suppose we need to integrate salesforce with any third party database(Netsuite,QuickBook) ok integrate with any third patry tool(SendGrid,Mandrill) at that time we are doing API request from apex class where we need to send request with the third party database/tool credentials.
- Here we can store those third party database/tool credentials in custom settings like Create a custom setting with two custom fields Username and Password. Use that custom settings in apex calss to send API request with username and password. That way in future if we need to update credentials, do not need to update apex code. We can change those credentials in custom settings.
https://www.verticalcoder.com/2012/07/26/custom-settings/
Let us know if this will help you
I have one more question
Custom Settings are used to replace the hardcoded value from your code. Let say you have a class in which you have hardcoded email address with some value but now you want to change it. Usually, this can be done simply by editing the class but as an admin, you are not supposed to do that. Here custom settings come into the picture where you just have to create a custom setting and refer it in a code so that if you want to change you have to edit the custom setting.
I hope this helps you.