1

I have a requirement in which when I select a particular value from a picklist,three new fields should pop up and need to be mandatory.These fields should pop up only when a value is selected from that field.

I have already created two page layouts and have added the fields to the different page layout.Please let me know the other steps. Is is possible without visualforce i.e. record type or page layout or dependent picklist

5
  • use reRender and Render attribute. Assign your PageBlock that has those three fields as some id. Sep 28, 2015 at 12:50
  • Is it possible without coding? Sep 28, 2015 at 12:52
  • 1
    In standard page layout it is not possible since the functionality is controlled by Salesforce itself. If you override with Visualforce page we can achieve it by reRender and Rendered attributes as mentioned by previous comments. Sep 28, 2015 at 13:00
  • you will have to create a visualforce page for this requirement
    – Novarg
    Sep 28, 2015 at 13:12
  • We've just published some new ways to do this. See my answer, below. Feb 4, 2018 at 1:59

4 Answers 4

1

For this requirement of yours you have to create a vf page with an dependent picklist. This dependent picklist value will display the fields value according to the selected picklist value. In my vf page I am changing the values of the dependent and depending picklist in my controller. So for your requirement you have to create your page and controller somewhat like this in which you have to change the field values depending on dependent picklist.

<----------controller----------->

public class dependcustompicklist {

    public String selectcity { get; set; }

    public String selectcountry { get; set; }

    public list <SelectOption> getcountry()
    {
        list <SelectOption> opt = new list <SelectOption> ();
        opt.add(new SelectOption ('','Select'));
        opt.add(new SelectOption ('India','India'));
        opt.add(new SelectOption ('US','US'));
        opt.add(new SelectOption ('UK','UK'));
        return opt;
    }

        public list <SelectOption> getcity()
    {
        list <SelectOption> opt1 = new list <SelectOption> ();
        if(selectcountry != null)
            {
                if(selectcountry == 'India')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('Kanpur','Kanpur'));
                opt1.add(new SelectOption ('Ghaziabad','Ghaziabad'));
                opt1.add(new SelectOption ('Noida','Noida'));
                }
                if(selectcountry == 'US')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('Washington DC','Washington DC'));
                opt1.add(new SelectOption ('New York','New York'));
                opt1.add(new SelectOption ('Los Angeles','Los Angeles'));
                }
                if(selectcountry == 'UK')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('London','London'));
                opt1.add(new SelectOption ('Paris','Paris'));
                //opt1.add(new SelectOption ('',''));
                }
            }
        return opt1;
    }
}

<----------Page-------------->

<apex:page controller="dependcustompicklist">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="Country Name">
                <apex:selectList value="{!selectcountry}" label="Country" size="1">
                    <apex:selectOptions value="{!country}" rendered="true"/>
                    <apex:actionSupport event="onchange" reRender="cu"/>
                </apex:selectList>
            </apex:pageBlockSection>

            <apex:pageBlockSection title="City Name" id="cu">
                <apex:selectList value="{!selectcity}" label="City" size="1" disabled="{!ISNULL(country)}">
                    <apex:selectOptions value="{!city}" rendered="true"/>
                </apex:selectList>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks.
0

You need to build a custom visualforce page to achieve this functionality. you can follow below steps.

  1. Create a new visualforce page
  2. Use actionsupport component (Action Support document)
3
  • Is is possible without visualforce i.e. record type or page layout or dependent picklist Sep 28, 2015 at 13:01
  • 1
    i dont think its possible without coding Sep 28, 2015 at 13:03
  • Without coding you can't do that
    – Himanshu
    Sep 28, 2015 at 13:05
0

By making the 'child' fields dependent, you can make them effectively not relevant (meaning no picklist options) with declarative tools. But there's nothing you can do declaratively to accomplish this easily. I'll offer that another option would be to use a visual workflow to populate the record. Then, based on selections, you can use the flow to require the child fields to be completed and then change the record type on create to adjust the page layout. But that's a lot of hoops.

0

We have recently published two new Flow Screen Components that greatly improve your ability to declaratively do this.

See:

https://medium.com/@alexedelstein/dynamic-questions-in-lightning-flow-b0269ee373ce

https://medium.com/@alexedelstein/dependentpicklists-a-flow-screen-component-c97dcee1796

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .