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

Standard Controller used VF page for Custom Object?

I am trying to understand standard controllers vs. custom--and how they can be used with Custom Objects?


Most of the code samples I have found all use the standard Account or Contact as the example like...


<apex:page standardController="Account" showHeader="true"  tabStyle="Account" > 


I have several Custom Objects that I have created---and have trying to create a simple Tabbed view of the object detail and related lists instead of the typical list view--using VF.


I am just starting on VF...


>Do standard controllers get 'auto-created' for each custom object?--assume so and thats how the display using standard SF look?


> When I try starting my VF page to be used on my Custom Object with...



<apex:page standardController="ThenameIusedtocreatetheobject_c" showHeader="true"  tabStyle="ThenameIusedtocreatetheobject_c"" > 



I get errors - ThenameIusedtocreatetheobject_c Does not Exist, etc.



What am I missing about standard controllers on custom objects?  Do all custom objects require a custom controller to be coded?


Thanks for the assistance...



Rajesh ShahRajesh Shah
StandardController for the custom Objects are also created automatically. You don't have to code for it. Not sure why you are getting the error. Hope you have appended the __c at the end of the object name.
Is the custom object deployed?  I believe it needs to be deployed before you could reference it with the VF page.

Did you ever receive an answer to this?  I am having the same issue - 


Laura did you ever find a solution for this error? I'm starting for the first time developing with visual force

Am working through the basic VF examples and seem to be having same problem as on this thread.  When I try to reference a custom object using the standard controller, I get an "Error pagename_c does not exist" message.


Using the most basic example, which seems to work fine with a standard object (accounts) creates this error when referencing a custom object.  


For example: 



<apex:page standardController="plan_c">


   Hello {!$User.FirstName}!    


   <p>You are viewing the {!} account.</p>





Above gives me an error saying custom object does not exist.  Tried many different things and can't seem to find a solution on the board.  Any ideas appreciated. 




As most of our custom objects are related to Standard objects I just created class extensions and had no other issues - Basically I have an AccountProgramDiscountExtension class that works for me


I know there was a response here that said the controllers were automatically built for custom objects but I have never been able to make it work -It appears that  Visualforce pages must inherit from a standard controller and be extended, not a custom controller if you wish it to be available to layouts.  After searching for an extraordinary amount of time on the boards I found that piece of info - that note also said it was documented but I sure have not been able to find it


Good luck!

Rajesh ShahRajesh Shah
I have never experienced this problem. I never had to do anything extra to create standardControllers for Custom Objects. Also after reading the above, I gave it another try with different options such as Deployed, In Deployment, through UI, through Eclipse and I was successful all the time. So not sure what exactly is the problem. But I did noticed that in both the code examples above, the custom object name has only 1 _c where in actuality it should have 2 like __c.

I think you need to remove the tabstyle attribute , incase you havent created a new tab for your application. maybe that could help.

this is just a suggestion , try it.


I think it should just be controller="plan__c"        NOT standardcontroller


Hi, I am also new to SF and was having the same problem, ie. getting "CUSTOMOBJECT_c not found" error.

Then I realized it is two underscores, not one, between CUSTOMOBJECT and c.

Now it works!


Wish SF explained this to us earlier...


Any solutions?


When I use


<apex:page controller="Client_Custom_Object__c">
   <apex:pageBlock title=" {!} CDI Report.!">

 I get an odd error: 


Error: The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.

This is the error one gets when one saves a VF page with a name of, say, "123" but my name is just letters, no spaces. 


jaw999, you should be using standardcontroller, not controller.


The controller attribute is to define a custom apex  controller, and standardcontroller is what you use to reference a standard object or a custom object.


Yes. I used standardController and found the relationship syntax error. But that's still an incorrect error message!


yeah. this is correct. I got the same issue. got through using <object__c>

This solution resolved my issue. thx!!
Mike VMCMike VMC
I'm receiving the same errors when trying to reference a custom object.

If I use <apex:page standardcontroller="Account" I do not receive an error.
If I use <apex:page standardcontroller="CustomObject" I get Error: CustomObject does not exist
If I use <apex:page standardcontroller="CustomObject__c” I get Error: Unknown property 'CustomObject__cStandardController.account'

If I use controller and the object API name I get:
Error: The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.
If I use controller and the object name I get: Error: Apex class 'CustomObject' does not exist

Any tips?
So 5 years later and still no answer?
its works fine  

<apex:page standardController="student__c" tabStyle="sport__c">
here student__c, sport__c are custom objects

David DurantDavid Durant
<apex:page standardController="WO_Comments__c">
    <apex:pageBlock title="Description" >
        <apex:pageblockTable value="{!WO_Comments__c}" var="WO_Comments__c">
             <apex:outputText value="{!WO_Comments__c.Comment__c}" />

I am having somewhat of the same issue.  I do not get an error however, the custom object will not appear after I enter the code in.

If you see the attached picture where I do apex:pageblock description it shows but, when for the custom object whether I do ouput text or pageblock table I cannot get the custom object to appear

User-added image
Below is what it should look like. This is the custom object I am referencing on a different page layout as an item of the related list.

User-added image

Any suggestions? Am I entereing the code incorrectly
Justin LeBlancJustin LeBlanc
This issue appears to be an order-of-operations problem.

Try saving the minimum VF page code possible to before expanding any further.
Rodrigo CabreraRodrigo Cabrera
Try this: Save the recordset variable, then use it as value in the table and set the table internal variable.
After this you can retrieve any object field using the internalvar.field in the column component.

<apex:page showHeader="false" sidebar="false" standardController="Account" recordSetVar="accounts">

<apex:dataTable value="{!accounts}" var="a">
            <apex:column value="{!a.field}" />

Hope this helps,
Emerge Admin UserEmerge Admin User
Thank you everyone .. this discussion thread is great and it really helped me.
I had the exact same requirement as in Keith's question.

I would like to share my brief solution that I got after I read each comment.

I have a custom object named Chair whose API name is Chair__c.
I wanted a plain VF page that simply lists out the chairs with its attributes. And I wanted to use StandardController.

Let me share the VF that worked perfectly for me.
So, here we go:

<apex:page standardController="Chair__c" recordSetVar="allChairs">   
    <apex:pageBlock >                
        <apex:pageBlockTable value="{!allChairs}" var="aChair">
            <apex:column value="{!aChair.Id}" />
            <apex:column value="{!aChair.Name}" />            
            <apex:column value="{!aChair.color__c}" />
            <apex:column value="{!aChair.material__c}" />

1. In order to refer the collection object of chairs with Custom controller, we can use the recordSetVar parameter of the apex page. Thanks Rodrigo, this reminder helped solve my problem in a jiffy !
2. As you can see the custom object is Chair__c and not Chair_c . Thanks for the reminder, Rajesh !
Needless to say, even the custom fields require the "__c". Eg: color__c

Thanks to all,


Sab L 10Sab L 10
If CustomObject__c doesnt exist error is thrown, one another reason might be permission for the user profile. Check whether user have view access to this object. To setup/view permission, Manage Users -> User Profiles -> Select Profile -> under Custom Object Permission check for permission details. I got same error, got resolved after providing right permission to the user profiles.
Hope this helps.
balaji gunasekaran 9balaji gunasekaran 9
Please try this. It is working.

<apex:page standardController="Policy__c">
<apex:form >
<apex:pageblock title="New Policy">
      <apex:inputField value="{!Policy__c.Name}"/>
      <apex:inputField value="{!Policy__c.Policy_Number__c}"/>
      <apex:inputField value="{!Policy__c.Current_Status__c}"/>
      <apex:commandButton value="submit" action="{!save}"/>
Yamini PandeyYamini Pandey
Hi All,
I was trying to run this piece of code. Lead is a custom object. I am getting the below error as   
ERROR:- Could not resolve field 'Lead_Name' from value binding '{!Lead.Lead_Name}' in page Apex_StandardController.
I tried appending __c in Lead (as it is a custom object), but I am reciving the same error again and again.

<apex:page standardController="Lead">
        <apex:pageBlock title="Lead" helpTitle="need Help??" helpUrl="/apex/Apex_CommandButton">
            <apex:pageBlockSection title="Basic Info" collapsible="false">
                <apex:inputField value="{!Lead.Lead_Name}"/>
                <apex:inputField value="{!Lead.Gender}"/>
                <apex:inputField value="{!Lead.Places}"/>
Anu majetyAnu majety
@balaji gunasekaran 9

Thanks alot it worked
Eric Latreille 8Eric Latreille 8

Hi Guys,

It seems to be a complicated issue and many of us have different results...

Why is it that this code works well:
<apex:page standardController="Account" recordSetVar="account" renderas="pdf">
   <apex:form >
    <apex:pageBlock >             
        <apex:pageBlockTable value="{!account}" var="a">
            <apex:column value="{!a.Id}" />
            <apex:column value="{!a.Name}" />     

But this one is not?

<apex:page standardController="Invoice__c" recordSetVar="invoice" renderas="pdf">
   <apex:form >
    <apex:pageBlock >             
        <apex:pageBlockTable value="{!invoice}" var="a">
            <apex:column value="{!a.Id}" />
            <apex:column value="{!a.Name}" />     

My Apex Class is:
global class attachPDFToInvoice {
    private final Invoice__c i; //Invoice object
    public attachPDFToInvoice(ApexPages.StandardController standardPageController) {
        i = (Invoice__c)standardPageController.getRecord();
    //method called from the Visualforce's action attribute
    public PageReference attachPDF() {
        //generate and attach the PDF document
        PageReference pdfPage = Page.PDF_Invoice;
        Blob pdfBlob; //create a blob for the PDF content
        if (!Test.isRunningTest()) { //if we are not in testing context
            pdfBlob = pdfPage.getContent(); //generate the pdf blob
        } else { //otherwise, we are in testing context and getContent() gets funky so create the blob manually
            pdfBlob = Blob.valueOf('Some Text for a boring PDF file...');
        Attachment attach = new Attachment(parentId = i.Id, Name = 'Invoice.pdf', body = pdfBlob); //create the attachment object
        insert attach; //insert the attachment
        //redirect the user
        PageReference pageWhereWeWantToGo = new ApexPages.StandardController(i).view(); //we want to redirect the User back to the Invoice detail page
        pageWhereWeWantToGo.setRedirect(true); //indicate that the redirect should be performed on the client side
        return pageWhereWeWantToGo; //send the User on their way


In all cases, the file is attached to my Invoice Custom Object but only the first example works with Account fields.

Thanks for your help!