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 

render visual force page with record type

Hi all,

I VF page below and have 2 URL
lobbyEditrelatedcontact?RecordType=01290000000iHY6
lobbyEditrelatedcontact?RecordType=01290000000iHYB

the first one for employee and second for the client . How can i assign VF page with record type and URL above

<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:column headerValue="Action">
             <!--<apex:commandButton value="Remove Row" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>-->
         </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 id="GvCHX" onchange="slideToggle" value="{!Contacts.cont.Government_Board_or_Committee_Member__c}"/>
         </apex:column>
         <apex:column headerValue="Details">
         
            <div id="GvCHXDetails" style="display:none">Age is something</div>
            
            <!--<apex:inputField id="GvCHXDetails" label="details" value="{!Contacts.cont.Details__c}"/>-->
         </apex:column>
         <!--<apex:column headerValue="Active">
              <apex:inputCheckbox value="{!Contacts.cont.Active__c}" />
         </apex:column>--> <!--this will be defaulted to TRUE on any new entry-->
             <apex:column headerValue="Add Declaration">
             <apex:inputCheckbox value="{!Contacts.cont.Declaration_Attached__c}" />
         </apex:column>
         <apex:column headerValue="Action">
             <!--<apex:commandButton value="Remove Row" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>-->
         </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>
Anupam RastogiAnupam Rastogi
Hi Huy,

As I understand, you are having two record types for your custom object. And you wish to associate the above VF Page with these record types.

If my understanding is correct then the following article should be helpful: https://help.salesforce.com/HTViewSolution?id=000044598&language=en_US (https://help.salesforce.com/HTViewSolution?id=000044598&language=en_US)

Please refer it and let me know if you need any further help.

Thanks
AR

If you found the reply useful which solves your problem then mark it as best.
Huy NguyenHuy Nguyen
Hi,
I found the solution but it need to be hardcorded. is any way to void it

 <apex:pageBlock title="Client" rendered="{!$CurrentPage.parameters.RecordType='01290000000iHY6'}">
Anupam RastogiAnupam Rastogi
Hi Huy,

I do not think this hard coding can be avoided, because based on this value only the page will know whether to render the page block or not. Moreover this is the record type Id which is not going to change for that particular record type. So you can very well use it.

AR
Huy NguyenHuy Nguyen
Hi ,

It is not changed when we deploy to another environment ?
Mudasir WaniMudasir Wani
Hi Huy,

Use custom label to store this value and update the value in other organizations.
Let me know if you have any question.

Please mark this as solution if this solves your problem, So that if anyone has this issue this can help
 
Anupam RastogiAnupam Rastogi
Hi Huy,

Yes the record type Ids will be different in different environments. So you can do the following. I did the same in a similar scenario in my app.

1. Within your custom controller create two new getter functions. One for the Employee record type and other for the Client record type.
2. These getter functions should query and retrieve the respective record type Id and compare it with the current page's record type Id. If it is same then return True else return False.
3. Call these getter functions from the rendered attribute of the respective pageblocks. You can use IF statement within the rendered attribute to see if True is returned or False and correspondingly show or hide the page block.

Let me know if you still find any issues, happy to help.

Thanks
AR

If you found the reply useful which solves your problem then mark it as best.