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
Krishna_225Krishna_225 

Dynamically populate picklist fields based on selected picklist value

Hi all,
I'm new to SF. I have a requirement where if a value from a region picklist(UK) is selected, it should unlock other picklist field with its sub-regions(UK). If other picklist value(Non uk) is selected, it should not populate. Can anyone help me with this requirement.

Thank you in advance
SK
Best Answer chosen by Krishna_225
jigarshahjigarshah
Sumanth,

You can use the Dependent Picklist feature provided by Salesforce to accomplish this requirement. The following articles should help you understand Dependent Picklists and how to implement them within Salesforce.
  • https://help.salesforce.com/articleView?id=fields_defining_field_dependencies.htm&type=5
  • https://help.salesforce.com/articleView?id=fields_dependent_field_considerations.htm&type=5
Please mark the thread as SOLVED and answer as the BEST ANSWER if it helps, address your issue.

All Answers

jigarshahjigarshah
Sumanth,

You can use the Dependent Picklist feature provided by Salesforce to accomplish this requirement. The following articles should help you understand Dependent Picklists and how to implement them within Salesforce.
  • https://help.salesforce.com/articleView?id=fields_defining_field_dependencies.htm&type=5
  • https://help.salesforce.com/articleView?id=fields_dependent_field_considerations.htm&type=5
Please mark the thread as SOLVED and answer as the BEST ANSWER if it helps, address your issue.
This was selected as the best answer
Krishna_225Krishna_225
Hi jigarshah, that was great!!
I have another requirement where a text box need to appear auotmatically when "Other" option is selected from a picklist. If I go with the formula, it wont be displayed on edit page. If I go with dependent picklist, it will be appeared before the option is selected. I'm pretty much confused on this. Can you please help me with this requirement.

Thanks in advance.
SK
jigarshahjigarshah
Krishna,

This can be implemented using a Visualforce that is added as a section within the standard page layout. The picklist which controls the rendering of the textbox as well as the text box field should only be included in the page.

You can then use the rerender attribute within the respective inputField tags of Visualforce, to display / hide the textbox field dynamically.

Things to note.
  1. Use <apex:inputField> to display the individual field.
  2. Use field sets instead of hardcoding the field.
  3. The Visualforce page implemented as a section of the standard page should have the standardController attribute within <apex:page> tag set to the name of the object whose standard page layout is being manipulated.
Krishna_225Krishna_225
Hi Jigarsah,
I tried doing that way. But the main prob is the added vf page is visible only on detail page but not on page where we create new record.
how to achieve that functionality
 
Krishna_225Krishna_225
below is my Code...Please suggest any edit w.r.t above requirement
<apex:page standardController="Lead">
    <apex:form >
    <apex:pageMessages id="theMessage"/>
                 <apex:pageBlock id="thePageBlock">
                          <apex:pageBlockSection title="Target Source Information" columns="2">
                                  <apex:actionRegion >
                                    Target Sectors:  <apex:inputfield value="{!Lead.Target_Sectors__c}" id="Type">
                                      <apex:actionSupport event="onchange" rerender="ProdFamilyModel,theMessage"/> 
                                      </apex:inputfield>
                                  </apex:actionRegion>
                          </apex:pageBlockSection>
                                <apex:outputPanel id="ProdFamilyModel">
                      <apex:pageBlockSection columns="2" id="ProdFamily"  rendered="{!IF(Lead.Target_Sectors__c == 'Other', true, false)}"> 
                            <apex:inputfield value="{!Lead.Please_specify_the_Other_reason__c}"/>
                 </apex:pageBlockSection> 
    </apex:outputPanel> 
    </apex:pageBlock>
    </apex:form> 
</apex:page>
jigarshahjigarshah
Krishna,

I am afraid then you may have to go the custom route which means writing a custom Visualforce that enables you to implement the hide / show behaviour.