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
Javier MaldonadoJavier Maldonado 

Hide a specific pick list Value based on two previous pick list field

I'm working to find the way how to hide 1 of the 3 values from my pick list field, based on 2 different previous value content... 

I have a field "length" (picklist  9, 18, 36), field "width" (picklist  1/4, 3/8, 1/2, 3/4, 1) and field "material" (x, y and z ). I would like to filter the field "length" based on Material_Field and Width_Field, so as described below:

User-added image

please put some code if it's possible. THANKS
Best Answer chosen by Javier Maldonado
Javier MaldonadoJavier Maldonado
This problem was solved... 

 <apex:selectList size="1" style="margin-left:-16px;" value="{!Customer_s_Price_List__c.Long_Imperial__c}">

 

All Answers

Hargobind_SinghHargobind_Singh
Hi Javier, Standard dependent picklist won't resolve your issue, as you are trying to use two picklists as master. 
You won't be able to do this on your standard page layout. However, you can write a VF page and use Javascript to do this. 

Here are two arcicles that could get you started: 
http://stackoverflow.com/questions/13925845/javascript-show-hide-based-on-dropdown
http://salesforce.stackexchange.com/questions/17837/using-javascript-to-change-or-remove-pick-list-values-on-vf-page
 
Javier MaldonadoJavier Maldonado
Thank... I will try...
Javier MaldonadoJavier Maldonado
The code below is running, but there is still a problem... the pick list behaviors is well, but when I saved the record I'm losing the value, so my goal is save the pick list's value in to the custom field Long_Imperial__c, has somebody worked on this?... Can somebody give me a hand???

Controller
    public string select_length {get; set;}
    public string var_length {get; set;}    
    public string var_width {get; set;}
    
    public List<SelectOption> getListWidth() {
        List<SelectOption> options = new List<SelectOption> { new SelectOption('','-- Width --') };
        for(Schema.PicklistEntry gr:Customer_s_Price_List__c.Wide_Imperial__c.getDescribe().getPicklistValues()) {
            options.add(new SelectOption(gr.getValue(),gr.getLabel()));
        }
        return options;
    }
    
    public List<SelectOption> getlength(){
    
        List<SelectOption> options = new List<SelectOption>();
        
            var_width = cpl.Wide_Imperial__c;
            
            if(var_width == null)
            return null;{
            if(var_Product_Type =='Laminated / + 10'){
                options.add(new SelectOption('9','9'));
                options.add(new SelectOption('18','18'));
            }
            if( var_Product_Type =='Plasma' && (var_width =='1/4' || var_width =='3/8' ) ){
                options.add(new SelectOption('9','9'));
                options.add(new SelectOption('18','18'));
            }
            if( var_Product_Type =='Plasma' && !(var_width =='1/4' || var_width =='3/8' )){
                options.add(new SelectOption('9','9'));
                options.add(new SelectOption('36','36'));
            }
        }
        return options;
    }


Visualforce
<apex:pageBlockSection title="Imperial System" columns="1" rendered="{!Customer_s_Price_List__c.System_Of_Measurement__c == 'Imperial System'}">
                             <apex:inputField value="{!Customer_s_Price_List__c.Wide_Imperial__c}"> 
                                 <apex:actionSupport event="onchange" reRender="size"/>
                             </apex:inputField>
                            <apex:outputPanel id="size">
                            <apex:pageBlockSection columns="1">
                                <apex:pageBlockSectionItem >
                                    <apex:outputLabel style="margin:16px;">Length (Yards)</apex:outputLabel>
                                    <apex:selectList size="1" style="margin-left:-16px;" value="{!select_length}">
                                        <apex:selectOptions value="{!length}"/>
                                    </apex:selectList>
                                </apex:pageBlockSectionItem>
Javier MaldonadoJavier Maldonado
This problem was solved... 

 <apex:selectList size="1" style="margin-left:-16px;" value="{!Customer_s_Price_List__c.Long_Imperial__c}">

 
This was selected as the best answer