Using one page and controller for both a “Detail Page Button” and a “List Button”


Force 201

See Correction section below the original post

Original Post

I have a Visualforce page that I want to use both for single objects (via a “Detail Page Button”) and for multiple objects (via a “List Button” with “Display Checkboxes” enabled). The page presents a table of the objects (with one row only for the single object case) and does its processing on each of the objects in the table.

This can be done with a single page and controller if the “URL” and “OnClick JavaScript” options are chosen for the “Content Source” of the custom buttons because then arbitrary parameters can be passed to an arbitrary page. But this post describes a way to get the “Visualforce Page” option for the “Content Source” to work instead. That means that the coupling between the buttons and page is more explicit, and more use is made of standard platform code and conventions.

View original post 193 more words