You need to sign in to do that
Don't have an account?

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...
KS
Did you ever receive an answer to this? I am having the same issue -
Thanks
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 {!plan_c.name} account.</p>
</apex:page>
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!
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
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>
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?
<apex:page standardController="student__c" tabStyle="sport__c">
</apex:page>
here student__c, sport__c are custom objects
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
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.
Any suggestions? Am I entereing the code incorrectly
Try saving the minimum VF page code possible to force.com before expanding any further.
Example: salesforce.com/us/developer/docs/pages/Content/pages_controller_std_associate.htm
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}" />
</apex:dataTable>
Hope this helps,
Rodrigo
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}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Notes:
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,
Deepak
(acecloudservices.in)
Hope this helps.
Please try this. It is working.
<apex:page standardController="Policy__c">
<apex:form >
<apex:pageblock title="New Policy">
<apex:pageblocksection>
<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}"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
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:form>
<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}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks alot it worked
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}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
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}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
My Apex Class is:
global class attachPDFToInvoice {
private final Invoice__c i; //Invoice object
//constructor
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!
Eric