Following on from the Initial Session “Salesforce for Domino Dogs” that Paul Mooney and I did at Engage and a modified version of which that has just been presented at #DNUG I figured that a series of dev articles on how you would do a job in Salesforce that you had always taken from granted in Domino might be a good idea, because:
These articles are not in any order and are not meant to represent any form of training guide.
So lets get started, first up: Profile Documents!!
In Domino you tend to store config settings for an app in a profile document1 for all your one off settings
To get the same features in Salesforce you use a ‘custom setting’ which does exactly the same job and has one huge advantage over using a normal Salesforce custom object that could do the same job.
(It should be noted that Domino profiles are nothing like Salesforce profiles)
To create a custom setting, go into Setup and search for “Custom Settings”
Click on the “New” button, and fill in some sane details, for normal configs i.e. stuff you would use system wide, select a setting type of “List”, if you want to use them for things like default values in fields and formulas then select “Hierarchy”
Click ‘Save’ and you now have a custom setting object, you can add one or more fields to it just as you would any other object in Salesforce
Added all the fields you want?, lets put in some data. if you go back to the list of custom settings you will see that you now have a “manage” link, click this
Then click “New”
Fill in the fields just like you would on a normal form, if this is a Setting there is only going to be one of, I tend to give it the same title as the name of the object to keep things simple, in this case “General Settings”, if you are going to use it multiple times than give it a name that will make sense in the context of your code
All done. now we can use the setting in our code and see the reason why we would use them vs. a normal custom object.
As you can see from the code below, you don’t have to use a Select statement, which means getting the settings wont count against your apex limits, HORRAY!!!
You just have to create a new instance of the setting object then you can just “getInstance” with the Name of the object you created to get the document back.
Well you are supposed to, but you never do thanks to the evil caching and the fact the are are a sod to just copy around, so you end up with a config document and a view you store them in. ↩