You need to sign in to do that
Don't have an account?
Javier 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:
please put some code if it's possible. THANKS
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:
please put some code if it's possible. THANKS
<apex:selectList size="1" style="margin-left:-16px;" value="{!Customer_s_Price_List__c.Long_Imperial__c}">
All Answers
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
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>
<apex:selectList size="1" style="margin-left:-16px;" value="{!Customer_s_Price_List__c.Long_Imperial__c}">