1

I'm trying to create a custom Visualforce page using the standard controller with a custom object.

Let's assume that I have named my customObject as CustomTable. On my Visualforce Page, I would then reference the custom object as a standard controller like this.

<apex:page standardController="CustomTables__c">
</apex:page>

The above code works fine, but when I try to change it to being singular with just "CustomTable__c" this throws an error saying that the custom object does not exist.

In my URL, I've also included a parameter like s:

https://salesforce_url/apex/customEditVFPage?id=XYZ

The id falls under Custom Fields & Relationships, so I had to manually create this.

Now, I'm confused because the fields for creating a Custom Object requires you to provide a Singular and Plural name. I would assume that by providing an ID on the url, this would let the Standard Controller pick up which to object query by using the ID and then I can reference the custom object using the Singular Standard Controller.

Also, a lot of examples/documentations would use singular labels "Account, Lead, Case" and then create a recordSetVar to obtain everything on the list.

Would it be better for me to just create a custom controller to handle this? Or am I approaching this in a totally wrong way?

The only change to the edit page is to change an input field into a dropdown and I feel like I have to do a lot of work just to make a small change.

  • This is just about how you name the object itself. You should choose singular API Names for your objects, but in this case someone chose a plural. You have to use the API Names as they are set up, or change them to what you want. – Adrian Larson Nov 7 '16 at 20:23
3

When you create a custom object you choose:

  • Label
  • Plural Label
  • Object Name

While it is convention to use a singular name for a table (AKA an SObject) it sounds like you chose a plural name. If you haven't gone too far in your development I suggest you change the "Object Name" back to the singular.

There is no automatic recognition of singular/plural naming in the product that I know of; the "Child Relationship Name" does get defaulted to a plural (or at least has an "s" appended) by the setup UI when a lookup relationship is created.

Providing the singular and plural form of the label allows a default detail page (where there is only one object) and a default list page (where there are many objects) to automatically use the right term.

If the standard controller does all you need just use it. If you require some extra code later you can add a controller extension class for that extra code and continue to leverage the standard controller. Another benefit of basing your page on the standard controller is that you can then override standard actions such as new and edit (if you wish) with your page; this allows you to replace the platform's default page everywhere without having to add custom links or custom buttons.

  • Especially +1 for suggesting changing it back to singular if the development is not too far in. – Adrian Larson Nov 7 '16 at 20:36
  • Thanks, that was suppose to be obvious for me, but I guess I missed it. Not too far from development, so I did get to change it back easily. Now, I just need to figure out how URL params work and overriding existing VF pages. – kev_panda Nov 7 '16 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.