2

When I choose my Visualforce Page appended to a Custom Button, I find that I cannot choose pages which use a custom controller at all, and sometimes just some of the pages which use the standard controller.

  • based on same SObject – C.William Oct 20 '16 at 14:32
2

For a Detail Button, you must implement StandardController, and for a List Button, you must implement StandardSetController.

Detail Button

<apex:page StandardController="MyObject__c">

List Button

<apex:page StandardController="MyObject__c" recordSetVar="records">

If you want to include any extensions, they must define a constructor that accepts the relevant controller.

Detail Button

public MyExtension(ApexPages.StandardController controller)
{
    // constructor logic
}

List Button

public MyExtension(ApexPages.StandardSetController controller)
{
    // constructor logic
}
| improve this answer | |
1

This is how Visualforce actions, buttons and links are designed to work. Pages that use standardController (and optionally recordSetVar) are intended to be used against a specific record or set of records from a given object type. You'll find tons of examples and explanations in the documentation, including Mass-Updating Records with a Custom List Controller, Overriding Tabs Using a Standard List Controller, Adding Custom List Buttons using Standard List Controllers, and other places as well. They allow you to define new actions for an object's home page, a button or link on a detail page, or a button on a related list or list view that contains that specific object type.

| improve this answer | |

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.