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
sylar20sylar20 

Dependent field in VisualForce

Hi,

 

I have configured a field dependency in my Case Object, but when i put in my VF page it doesn't work the way it does in the standard page layout. Both the fields show all picklist values. No dependency is working.

 

Following is my VF code to include those two fields in the VF page.

 

Controlling Field: Department

Dependent Field : Case Reason

 

<apex:inputField required="true" value="{!Case.Department__c}"/>
         <apex:inputField required="true" value="{!Case.Case_Reason2__c}">

 

 

Best Answer chosen by Admin (Salesforce Developers) 
sales4cesales4ce

Interesting!

I do not see anything wrong with the code. Its working for me! The same code.

I am assuming your VF page version is 21.0 and you have correctly configured the dependent picklists.

From a standard UI were you able to access the controlling and dependent fields correctly?

 

Sales4ce

All Answers

sales4cesales4ce

I don't see anything wrong with the code posted except that the second Input Field tag should be closed. Your page should render the dependent picklists without any issues.

<apex:inputField required="true" value="{!Case.Department__c}"/>
         <apex:inputField required="true" value="{!Case.Case_Reason2__c}"/>

I might be curious to know the Visual Force Page Version.

 

Let me know if was some help.

 

Thanks,

Sales4ce

sravusravu

In one of my requirements i have used the field dependencies in the visualforce page  and it worked fine for me. The version of my page was 19.0 and i used on that same Case object.

 

Try removing "required=true".

 

<apex:inputField value="{!Case.Department__c}"/>

<apex:inputField value="{!Case.Case_Reason2__c}"/>

sylar20sylar20

I have already tried removing required=true.. Still it doesn't work.

Will troubleshoot again and update..

 

Thanks

sravusravu

Are you using standard controller or custom controller?

sales4cesales4ce

Can you post the complete code including VF page and any customer controller, if there is one to better help you with the issue.

 

Sales4ce

sylar20sylar20

HI,

 

I am using the standard controller Case.

 

Following is my VF Page Code:

 

<apex:page standardController="Case" tabStyle="Case" standardstylesheets="true">


    <apex:sectionHeader title="{!$ObjectType.Case.label} Edit" subtitle="{!Case.Casenumber}"/>
    <apex:form >
    <apex:pageBlock id="thePageBlock" title="{!$ObjectType.Case.label} Edit" mode="edit">
    
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>   
        </apex:pageBlockButtons>
        
        <apex:pageBlockSection showHeader="true" title="Case Information" columns="2">
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Case Owner"/>
                <apex:outputText value="{!Case.Owner.Name}"/>
            </apex:pageBlockSectionItem>
            <apex:inputField required="true" value="{!Case.Status}"/>
            <apex:inputField value="{!Case.Priority}"/>
            <apex:inputField required="true" value="{!Case.ContactId}"/>
            <apex:inputField required="true" value="{!Case.AccountId}"/>
            <apex:inputField required="true" value="{!Case.Origin}"/>      
            <apex:inputField value="{!Case.Account_Set_Up__c}"/>
            <apex:inputField required="true" value="{!Case.FCR__c}"/>
            <apex:inputField value="{!Case.User_Set_up__c}"/>
            <apex:inputField required="true" value="{!Case.Complaint__c}"/>
            <apex:inputField value="{!Case.EChain_Contact__c}"/>
            <apex:inputField required="true" value="{!Case.Route_to_Helpdesk__c}"/>
            <apex:inputField value="{!Case.Escalated_to_Ops_QA__c}"/>
            <apex:inputField value="{!Case.Source__c}"/>
            <apex:inputField value="{!Case.CSE_Case_Number_For_Ops_QA_only__c}"/>
            <apex:inputField value="{!Case.Escalation_Assist_Log__c}"/>
            <apex:inputField value="{!Case.CSR__c}"/>
        </apex:pageBlockSection>
        
       <apex:actionRegion >
         <apex:pageBlockSection showHeader="true" title="Case Department and Reason" columns="1">
         <apex:inputField required="true" value="{!Case.Department__c}"/>
         <apex:inputField required="true" value="{!Case.Case_Reason2__c}">
                          <apex:actionSupport event="onchange" rerender="thePageBlock" status="Status2"/>
         </apex:inputField>
 
        </apex:pageBlockSection>
        </apex:actionRegion>

        
        <apex:pageBlockSection showHeader="true" title="Description Information" columns="1">
            <apex:inputField value="{!Case.Subject}"/>
            <apex:inputField value="{!Case.Description}"/>
            <apex:inputField value="{!Case.Action_Taken__c}"/>
        </apex:pageBlockSection>
 
         
         <apex:actionRegion >
    
 
         <apex:pageBlockSection showHeader="true" rendered="{!(Case.Department__c == 'Criminal' && Case.Case_Reason2__c == 'Applicant Dispute' && Case.CreatedBy.UserRole.Name == 'Client Services - Sterling East')}" title="Client Facing Criminal Dispute Information" columns="2" >
            <apex:inputField value="{!Case.Dispute_initiated_by__c}"/>
            <apex:inputField value="{!Case.Applicant_Name__c}"/>
            <apex:inputField value="{!Case.Client_Name__c}"/>
            <apex:inputField value="{!Case.Jurisdiction_1__c}"/>
            <apex:inputField value="{!Case.Order__c}"/>
            <apex:inputField value="{!Case.Jurisdiction_2_Optional__c}"/>
            <apex:inputField value="{!Case.Client_Email_Address__c}"/>
            <apex:inputField value="{!Case.Jurisdiction_3_Optional__c}"/>
            <apex:inputField value="{!Case.Client_Email_Address_Optional__c}"/>
            <apex:inputField value="{!Case.Applicant_Dispute_Notification__c}"/>
            <apex:inputField value="{!Case.Client_Email_Address_Optional2__c}"/>
            <apex:inputField value="{!Case.Applicant_Dispute_Resolve_Favour__c}"/>
            <apex:inputField value="{!Case.Client_Email_Address_Optional3__c}"/>
            <apex:inputField value="{!Case.Applicant_Dispute_Resolve_Not_Favour__c}"/>
        </apex:pageBlockSection>
     
       </apex:actionRegion>
        
        <apex:pageBlockSection showHeader="true" title="Dispute Information" columns="2">
            <apex:inputField value="{!Case.Dispute_Investigator__c}"/>
            <apex:inputField value="{!Case.Dispute_Jurisdiction__c}"/>
            <apex:inputField value="{!Case.Dispute_Resolution__c}"/>
            <apex:inputField value="{!Case.Dispute_re__c}"/>
            <apex:inputField value="{!Case.Business_Line__c}"/>
            <apex:inputField value="{!Case.Reason_Detail__c}"/>
        </apex:pageBlockSection>
        

    </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

sales4cesales4ce

Interesting!

I do not see anything wrong with the code. Its working for me! The same code.

I am assuming your VF page version is 21.0 and you have correctly configured the dependent picklists.

From a standard UI were you able to access the controlling and dependent fields correctly?

 

Sales4ce

This was selected as the best answer
sylar20sylar20

Ahhhhhrg.. It was the API 15 which i have selected.

Its 21.0 now. Thanks salse4ce