[SalesForce] Custom Object as Standard Controller: Plural Or Singular

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.

Best Answer

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.