+ Start a Discussion

Use a Visual Force page when viewing a specific record type

Newbie to Visual Force


Currently I have 3 Account record types:





Account Group


The first two use a standard account page


The last one uses a standard page Account Group.


I would like to build a Visual Force page for when users are viewing an Account Group record type.


Is this possible and how would I achieve this?


I would prefer to continue using a non Visual Force page for normal Accounts as this is much easier to maintain using drag and drop.


My Account Group layout only has a few fields and related lists so will be easy to maintain as a Visual Force page. My reason for wanting to use Visual Force for the Account Group is to be able to have different labels for some of the fields, to get rid of the view hierarchy link etc. etc.

Cory CowgillCory Cowgill

Take a look at using the <apex:detail> tag. This tag is a special tag which allows you to essentially pull in the standard page layouts for objects into a Visualforce Page. This sounds like what you want to do. Then when you load up a Record Type of "Account Group" or whatever, you can dynamically render content however you want.


Thanks for that.


So how would I implement this?


When a user searches for an account, clicks a recent link, clicks a link in a report etc. I need the page to open with a standard view if normal account and with  VF if Account Group.


So would I create a Visual Force page and us.e the button and links to override


Then have an IF statement round the code so depending on record type, it displays the standard page or custom code?


High level - what would the logic of this code look like?

Cory CowgillCory Cowgill

It would look like this (kind of)


<apex:page .....>

<apex:detail rendered="{!rec.RecordType != your custom type}"/>

<apex:pageBlock rendered="{!rec.RecordType == groupType}">

 ..... All your custom fields




You can use the RENDERED attribute to display / not display sections of code in a VF page based on an expression or boolean in your controller.


Once you have the VF Page above you will go into setup - customize and override the View link for the Record.


Thanks Cory, that's really helpful. Will give it a try next week


Hi Cory,


Sorry I am struggling to get this code to work.


I get the following error message: Error: Unknown property 'AccountStandardController.rec'


<apex:page standardController="Account"  >

<apex:detail rendered="{!rec.RecordType != '012S00000008m3Q' }"/>
<apex:pageBlock rendered="{!rec.RecordType == '012S00000008m3Q'}"> 




Cory CowgillCory Cowgill

Change rec to account.


For example,


{!account.RecordType != 'XXXXXXX'}