I am trying to control the visibility of a field in Visual force page based on record type selected while creating the record using below line.

 <apex:inputField value="{!obj.RequestType__c}"  rendered="{!cr.recordType.Name == 'Organisation'}">

Scenario : I have created a 'New' button for a custom object which is using this VF page. The record has 2 different record types and based on the different record type selected user should be able to see different fields.

Suppose, I have two record type 1) Insert and 2) Update ...here field A which appears on Insert case , should not come up if Update record type is selected in the VF page and vice versa

The page is saved without error but field is coming off every time irrespective of record type selected. Kindly let me know if there is any syntax error.

  • possible duplicate of salesforce.stackexchange.com/questions/96178/… Oct 17, 2015 at 12:33
  • It might be helpful to share some more about the use case here for your RecordTypes. Using RecordTypes for managing different states like Insert vs Update feels like an anti-pattern for RecordTypes. Oct 17, 2015 at 13:15
  • @KevinO'Hara : this requirement caters to a support process where in user can login as request for a new record creation and hence Insert RT is usedor may request for updation of an existing record, and hence Update RT is used. Let me know if this helps.
    – CRM Guy
    Oct 17, 2015 at 13:48
  • Ahh, I see. That makes more sense. Oct 17, 2015 at 19:10

2 Answers 2


Other way round you can put the record type field on your VF page and render the block containing remaining fields and it will change on choosing the record type on VF page.

<apex:inputfield value="{!object.recordType}"> // To select the record type

<apex:pageblocksection columns="1" id="pbs1" rendered="{!object.recordType == 'myRecType1'}">
     </apex:inputfield> // Your Fields to be displayed 

This way you can use the AJAX feature to change the fields on the fly on the VF page.

  • @ Nishant Singh - yes..that could be ..but thing is , I would not allow user even to see the other options if he/she does not have the permission to view that option.
    – CRM Guy
    Oct 18, 2015 at 5:52
  • 1
    You can also redirect the user to standard record type selection page and on selection redirect to the VF page. Oct 18, 2015 at 16:22

To redirect the page to record type selection and then to VF page you can follow this following approach.

https://{SFDomain}/setup/ui/recordtypeselect.jsp?ent={ObjectName}&retURL=/{Object KeyPrefix}/o&retURL=/{Object KeyPrefix}/o&save_new_url=/apex/{VFPageName}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .