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
Huy NguyenHuy Nguyen 

Record type in VF page

Hi all,

I have a page below :I have 2 record type :Client and Employee when we click add new it will redirect to according function. In here I create a page with 2 section appear together. How can I handle this requirement. The below page only appear with 1 section
<apex:page controller="LobbyEditRelatedContactController" tabstyle="Account">
 <apex:form >
   <apex:pageBlock title="Client">
      <apex:pageBlockTable value="{!lstContacts}" var="Contacts" id="wtable">
         <apex:column headerValue="Appointment">
            <apex:inputField value="{!Contacts.cont.Lobbyists_Appointment__c}"/>
         </apex:column>
         <apex:column headerValue="Name">
              <apex:inputField value="{!Contacts.cont.Client_NameUSER__c}"/>
         </apex:column>
         <apex:column headerValue="ABN">
         <apex:inputField value="{!Contacts.cont.ABNUSER__c}"/>
         </apex:column>
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable" immediate="true">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable" immediate="true">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlock>
   <apex:pageBlock title="Employee">
      <apex:pageBlockTable value="{!lstContacts}" var="Contacts" id="wtable1">
         <apex:column headerValue="Appointment">
            <apex:inputField value="{!Contacts.cont.Lobbyists_Appointment__c}"/>
         </apex:column>
         <apex:column headerValue="Name">
            <apex:inputField value="{!Contacts.cont.Employee_NameUSER__c}"/>
         </apex:column>
         <apex:column headerValue="Position">
            <apex:inputField value="{!Contacts.cont.Position__c}"/>
         </apex:column>
            <apex:column headerValue="NSW Gov board ?">
            <apex:inputCheckbox value="{!Contacts.cont.Government_Board_or_Committee_Member__c}"/>
         </apex:column>
            <apex:column headerValue="Details">
            <apex:inputField value="{!Contacts.cont.Details__c}"/>
         </apex:column>
             <apex:column headerValue="Active">
              <apex:inputCheckbox value="{!Contacts.cont.Active__c}" />
         </apex:column>
             <apex:column headerValue="Add Declaration">
             <apex:inputCheckbox value="{!Contacts.cont.Declaration_Attached__c}" />
         </apex:column>
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlock>
 </apex:form>
</apex:page>

 
sandeep sankhlasandeep sankhla
Hi Huy,

Use rendered for rendering your pageblock conditionally..In class you will come to know whihc recordtype is there so based on that you can render your pageblocks..

Keep 2 variable in class:

public Boolean  isEmployee {get;set;}
public Boolean isClient       {Get;set;}


//initalize by default to false in your constructor

isEmployee  = false;
isClient       = false;

now check if recordtype is emplyee then make employee true else client one true

if(Recordtype == Employee)
   isEmployee   = true;
else if(Recordtype == Employee)
  isClient       = true;


now in page add the rendered condition in pageblock like

1.  <apex:pageBlock title="Client" rendered="{!isClient }">
</apex:pageblock

2. <apex:pageBlock title="Employeet" rendered="{!isEmployee }">
</apex:pageblock


As I mentioend above you can render these block conditionally

Please check and let me know if it works for you

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer