+ Start a Discussion
Joseph DindingerJoseph Dindinger 

Why does $RecordType.Name break a VisualForce "New" record page?

Does anybody know if this is a bug, or if there is a reason for this?

If I create a VisualForce page to use as the "New" insert page for Leads, something like this simple example:
<apex:page standardController="Lead" >
    <apex:sectionHeader subtitle="{!Lead.Name}" title="Lead Edit"/>
    <apex:form >
        <apex:pageBlock title="Lead Edit" mode="edit" >
            <apex:pageBlockButtons location="top" >
                <apex:commandButton value="Save" action="{!save}" />
                <apex:commandButton value="Cancel" action="{!cancel}" />
            <apex:pageBlockSection title="Lead Information" columns="1">
                <apex:inputField value="{!Lead.firstName}"  />
                <apex:inputField value="{!Lead.lastName}" />
                <apex:inputField value="{!Lead.Company}" />
                <apex:inputField value="{!Lead.Phone}" />
                <apex:inputField value="{!Lead.MobilePhone}"  />
                <apex:inputField value="{!Lead.Email}" />
                <apex:inputField value="{!Lead.Error__c}" />

Notice that the last field is a custom field.  This is a text field where I want to populate a default value.  If I use something like "Default Value" it will work fine, and even if I use the formula editor to enter a value like $Organization.Id, it will still work.  However, if I enter $RecordType.Name, it will break the page and give me an error like this:

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

If I use the standard Salesforce view instead of overwriting it with a VisualForce page, this field works just fine, and shows the Record Type name.

Any help would be greatly appreciated!




Joseph DindingerJoseph Dindinger
The entry as the default for the custom field