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
Vegaln1Vegaln1 

How to Display the RecordTypeId field in Visual Force page.

Hello, I would like to display the name of the RecordTypeId field in a VF page. If I use the following

<apex:outputField value="{!NewOpp.RecordTypeId}"/>

 I recieve this error : RecordTypeId is a unsupported field value. However,  I can display the actual Id value by using this:

 

<apex:outputText value="Record Type Id :{!NewOpp.RecordTypeId}"/>

 but I want to Display the Name of the RecordType, for Example 'New Oportunity Record Type' and not the 18 character Id. 

 

Any ideas on how to accomplish this?

 

Regards,

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Vegaln1Vegaln1
Thank you bma, the actual syntax is:

<apex:outputField value="{!Opportunity.RecordType.Name}"/>

But you certainly put me on the right track... thanks again.

 

Regards,

All Answers

bmabma

RecordTypeId is a reference field type, which is described in the API Dev Guide. You can drop the "Id" at the end of the reference field to access the referenced object.

 

In this case, you can directly access the name field of the RecordType with the following:

 

<apex:outputField value="{!NewOpp.RecordType.name}"/>

 

 

 

Vegaln1Vegaln1

Thank you for your response, however, what you suggest outputs the literal 'name' and not the actual name of the RecordType.

 

Regards,

Vegaln1Vegaln1
Thank you bma, the actual syntax is:

<apex:outputField value="{!Opportunity.RecordType.Name}"/>

But you certainly put me on the right track... thanks again.

 

Regards,

This was selected as the best answer