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
Josh GallagherJosh Gallagher 

How to hide a field based on picklists

I am trying to create an invisible picklist called "Subcommittee" and only when certain values in "Type" and "Subtype" fields are picked. Then the Subcommittee picklist will appear and they can choose their selection. I know this has to be done by VF. 

 
Josh GallagherJosh Gallagher
I get the error "Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Case.Type" And when i take out Case Type I get the same Error but with Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Case.SubType__c.

Please see my current code

VisualForce Page:

<apex:page standardController="Case" extensions="customCaseController" id="pg">

    <apex:form id="frm">

        <apex:pageblock id="pb">

            <apex:pageBlockSection id="pbs" columns="2" title="Information">

                <apex:inputField value="{!theCase.Type}"/>

                <apex:inputField value="{!theCase.SubType__c}"/>

                <apex:inputField value="{!theCase.Subcommittee__c}" rendered="{!!isVisible}"/>

            </apex:pageBlockSection>

        </apex:pageblock>

    </apex:form>

</apex:page>



Apex Classes:


public with sharing class customCaseController {

    public Case theCase {get;set;}

    public boolean isVisible{get;set;}

     

    public customCaseController(ApexPages.StandardController stdcontroller) {

        isVisible = false;

        String AccountId = ApexPages.currentPage().getParameters().get('id');

        if(CaseId != null){

             Schema.DescribeSObjectResult r = Case.sObjectType.getDescribe();

             theCase = (Case) stdController.getRecord();

             if(theCase != null){

                if(theCase.Type == 'Advisory Committee' && (theCase.SubType__c == 'EAC'))

                    isVisible = true;

             }

        }

    }

}