function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chris GoderieChris Goderie 

More efficient use of Custom Fields and how to set defaults on them

Hello. I am pretty new to the Salesforce custom development but I have 2 (simple?) questions. In our company we are using 2 categories in multiple objects: "Brand" (single pick-list) and "Focus" (multi-select pick-list) and these 2 fields are being linked (Brand is controlling field for Ficus) meaning that based on selected Brand only valid Focus-values for that Brand can be selected. We have these Custom fields in many Salesforce-objects like: Account, Lead, Oppertunity etc.
  • Q1: is there a way in Salesforce to only set-up these Custom fields once and use them in multiple objects so maintaining them is much more easy?
  • Q2: we also have the Brand and Focus custom fields added to the User object. Currently we are building a new custom object for Sales Calls and also here the Brand and Focus is used. Is there a way to default the Brand and Focus values in this object based on the values from the user's User object? 
bob_buzzardbob_buzzard
Q1 - no.  The only way to get that kind of re-use would be through Visualforce, but that would mean overriding the create/edit pages for the sobjects in question.  You could copy the metadata between the object definitions using the Force.com IDE or migration tool, but you'd still be replicating it for each sobject.

Q2 - unfortunately not for picklists.  For other field types (text for example), you can specify a default value using a formula containing fields from the context user.  However, picklists only allow you to specify a value from the list as the default for every user.
Chris GoderieChris Goderie
Thanks very much Bob, just one more Question about Visualforce: if we would decide to do this would that mean that if I would change picklist-values in these objects at one central place (metadata?) these automatically would be updates in all objects or is still replicating required? I am just wondering if this all would make sense as the field-values are not changing that often.....
bob_buzzardbob_buzzard
If you went Visualforce you'd probably use text fields and generate the picklist elements programmatically - the configuration would be stored in one place, but probably in a custom setting rather than as field metadata.