I am trying to develop a visualforce page that will display different sections based on record type. I have gotten the page to work as expected upon creating a new record; however, when an existing record is edited the dynamic sections do not display at all (i.e. all that is displayed upon clicking Edit is the Detail section - see code below). I suspect this must be caused by the visualforce page not pulling the record type when the edit button is clicked but I do not know how to remedy this. Any thoughts? Code below:

    <apex:page standardController="QA__c" sidebar="false">
 <apex:stylesheet value="{!$Resource.QA_Style_Sheet}"/>
 <apex:form >
 <apex:pageMessages />
 <apex:pageBlock title="QA Scoring Form">
 <apex:pageBlockButtons >
     <apex:commandButton action="{!save}" value="Save" />
     <apex:commandButton action="{!cancel}" value="Cancel"/>
 <!-------- Start Top Detail Section ---------->
  <apex:pageblockSection title="QA Information" columns="2">
      <apex:inputField required="true" rendered="true" value="{!QA__c.Reviewee__c}"/>
      <!--<apex:inputField value="{!QA__c.Reviewer__c}"/>-->
      <apex:inputField required="true" value="{!QA__c.Type__c}"/>
  <!-- End Detail Section -->

  <apex:outputPanel rendered="{!QA__c.RecordTypeId == '012U0000000QpkU'}" > 

  <!-- Start Compliance Section -->
  <apex:pageBlockSection title="Compliance">
        <apex:pageBlockSectionItem >    
           <apex:outputLabel value="1) Professionalism / Proper Greeting / Positive Tone"/>
           <apex:panelGrid columns="2">
               <apex:inputField value="{!QA__c.Professionalism_Proper_Greeting_Etc__c}"/>
               <apex:inputField value="{!QA__c.Professionalism_Prop_Greet_Comments__c}" label="Comments"/>
  <!-- End Compliance Section -->


  <apex:outputPanel rendered="{!QA__c.RecordTypeId == '012c00000001Ihx'}" >

  <!-- Start Outbound Technique Section -->
  <apex:pageBlockSection title="Outbound Technique">
        <apex:pageBlockSectionItem >    
           <apex:outputLabel value="1) Prepared for Call / Appropriate Greeting / Response"/>
           <apex:panelGrid columns="2">
               <apex:inputField value="{!QA__c.Preparation__c}"/>
               <apex:inputField value="{!QA__c.Preparation_Comments__c}" label="Comments"/>
  <!-- End Outbound Technique Section -->


  • Have you overridden the "Edit" action on the QA__c object so that it goes to this new page rather than the default "Edit" page? – Jeff Bennett Aug 15 '17 at 15:03
  • yes - it displays the visualforce page upon clicking edit but only the Detail section (which is not dynamic) appears. – Kevin Ross Aug 15 '17 at 15:07
  • A few questions. 1. Are you certain this record has a record type assigned. 2. You may try evaluating against the 18 digit record type id instead of the 15. However, it would be best to set the record type id you are searching for in a variable in your controller instead of hard coding it. Ids change from environment to environment. – JRiffe Aug 15 '17 at 22:30
  • Yes the record type is assigned - when first creating the record, a dropdown appears to select which record type. The Visualforce page then works properly for the new record. The issue is when I edit any of these records, the VF page no longer displays those dynamic sections and only shows the Detail section that appears for all record types. I also tried using the 18 digit Id but this only made things worse and the VF page would not work correctly even upon first creating the record (instead the VF page would only display the Detail section). – Kevin Ross Aug 16 '17 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.