You need to sign in to do that
Don't have an account?

Context-sensitive Visualforce Form?
I am using a Visualforce form page to gether information needed to quote our various types of products. Considering all of our various products, I only need to gather about 20 fields of information to define the required attributes to accurately quote any of them (limited example below). My challenge is that on a handful of attributes (fields) apply to any one product, and I do not want to be asking the user questions that do not apply to the product they want quoted.
How can I educate my one form to show or not show form fields based on a product code that is passed to the Visualforce form when it is generated?
I have looked at many Visualforce and apex samples, gone through the Componenet Reference, and attempted a number of approaches, but feel that I'm running in circles.
Record Type is not an appropriate choice, and dependint picklists would involve too many variables. I am hoping for some type of 'IF' or 'CASE' logic that is based on a table of include/exclude values for each product, but I am not sure how to make the IF or CASE piece work.
Thanks for your assistance.
<apex:page setup="false" showHeader="true" sidebar="true" standardController="Opportunity">
<!-- Begin Default Content REMOVE THIS -->
<apex:sectionHeader title="Request for Quote Questionnaire" subtitle="Complete **the following for a prompt and accurate quote for {!opportunity.Product_Code_List__c}"/>
<!-- <apex:detail subject="{!opportunity.ownerId}" relatedList="false" title="false"/> -->
<apex:form id="quoteRequestInfoForm">
<apex:pageBlock title="quoteRequestInfo" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!delete}" value="Delete"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
<apex:commandButton action="{!save}" value="Save and Request PM Assistance"/>
<apex:commandButton action="{!save}" value="Save and Submit Quote Request"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!opportunity.Product_Code_List__c}"/>
<apex:inputField value="{!opportunity.Quote_Sub_Products__c}" />
<apex:inputField value="{!opportunity.QSmallest_Panel_Size__c}"/>
<apex:inputField value="{!opportunity.QHighest_Hole_Count__c}"/>
<apex:inputField value="{!opportunity.Q_Construction__c}" />
<apex:inputField value="{!opportunity.QCoppers__c}" />
<apex:inputField value="{!opportunity.QRequested_MCM__c}" />
<p>Additional Quote Instructions:</p>
<apex:inputTextarea cols="120" value="{!opportunity.Quote_Instructions__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<!-- End Default Content REMOVE THIS -->
</apex:page>
This sounds like a good job for field sets. I could envision creating a field set per product type and then having some logic based on the incoming product type parameter to determine whether or not that field set is rendered.
Something like...
Thanks for the lead, Tom. I have not yet explored Field Sets, but will do that. If anyone has a specific example of this working for a similar situation, I would appreciate it.
Bob