Using Visualforce Pages as Custom Actions

If your Visualforce page is used as a custom action, design it so that it either acts upon a single record provided by a standard controller or finds and acts upon a record or records your custom controller code retrieves.

Custom Actions on an Object

Visualforce pages added as custom actions on an object are invoked in the context of a record of that object type. That is to say, the custom action has a specific record ID handed to it, the record the user was looking at when they clicked the custom action, and the page should be designed to act upon that specific record type.

Visualforce pages used as custom actions on an object must use the standard controller for that object. Use controller extensions to add custom code, including @RemoteAction methods you can call using JavaScript remoting.

Your custom code may very well do more than make updates to the originating record. For example, the Create Quick Order custom action searches for matching merchandise, and creates an invoice and line item, all as part of creating an order for a part. That logic occurs in the context of the originating account record—the invoice is associated to the account record where the quick order action was invoked.

As a general rule, when the action completes, the user should be redirected to a page related to the originating record.

Custom Global Actions

Visualforce pages used as global actions can be invoked in many different places, and don’t have a specific record associated with them. They have complete “freedom of action,” which means it’s up to you to write the code.

More specifically, Visualforce pages used as global actions can’t use any standard controller. You must write a custom controller to handle the page. Your code might create one or many records, modify found records, and so on.

When a global action completes, the user should usually be either redirected to a parent record created as part of the action, or returned to where they started.