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

Best Way to Dynamically Present Fields based on Picklist Selection?

I have several custom objects that I need to collect and display different detail fields based on the users selection of type on the object.  


I have reviewed VF for custom page...looked at using Record Type but it seemed is is designed to present different field groups based on roles? ... and I know that APEX - AJAX would get the result.  


I am new to SF and trying to determine the fastest, easiest, & best way to achieve the functionality. 


Specifically the user would select a field value from picklist to indicate the type record...the other fields to be completed would be dynamically displayed based on the type selected...each type on the picklist would have its own group of relative fields.


Thanks for the advice and feedback.




I am relatively new to SF as well, but if I understand correctly, I think Record Type may

do exactly what you want.


We did something similar to what you are talking about at our organization.


We set it up so that there was a picklist of various item types, and based on the users

selection a specific set of fields are displayed. Using this method, we were also able to

determine which field values displayed in the picklists that were common to more than

one layout (ie: if item a only used values 1, 2 & 3 from a picklist but item b used values

2, 3 & 4 from the same picklist, we were able to dictate which values would be displayed

for each item so only the correct values showed).


We have not needed to have additional customizations based on roles, but can always

do so in the future if we see the need.


Does this sound like what you are trying to do? 



Without getting in to tons of programming, there are a couple of out-of-the-box features that might help.


The first is record types as you suspected, this allows you to program which page layout (collection of fields) that a user is presented with after they make an initial selection.


The second is called field dependancy where values available to a user in a picklist field get filtered based on the value they enter in another field.  For example you might have a "Reason Lost" field that is only active if the sales stage is Closed Lost.  However, this option can't be used to make a field completely appear or disappear.


Finally you might consider validation rules where depending on the entries a user has put in you can make some fields conditionally required.  For example if a user selects "Lost to Competitor" but leaves a custom field Main Competitor blank, they would not be allowed to save the record.


Hope this helps!