When creating a cutrom button on a related list (say the functionality is create a new task), why does my VF/Apex need to make use of the standard list controller (standardcontroller with the recordSetVar attribute defined on your page)? Why not just the standard controller, since in this case, I'm not acting on/displaying a set of records?

2 Answers 2


I completely agree. If you're not acting on a specific set of record in the related list with your custom button, i.e. if you're building a custom New button, there really isn't any need for a standard set controller. IMHO, salesforce should just have a standard way of passing over the details to a custom button and leave the visualforce page developer to figure out whether to implement with a custom controller, standard controller, or standard set controller depending on their specific requirements.

So why is it needed? I can only guess, but I would assume it's to prevent administrators from accidentally wiring up a button to a visualforce page that may not be able to accept your input.

That said, there are two ways to work around this. First, use a url for the source of your button. Using your example of a new task button on say an account record you could do


Second, you can create the page and set the recordset var, create the button, then just edit your page. Once the button has been set up it doesn't enforce maintaining the recordsetvar attribute (although it may complain if you try and edit the button later).

  • Hi Ralph, I considered suggesting the workarounds you proposed in my answer, but decided against it for the simple reason that I can't understand why someone would need a workaround. What are your reasons for not wanting to use a StandardSetController? May 8, 2013 at 23:29
  • It's not that I don't want to use the StandardSetController, I just can't see a reason for using it. This sort of use case the primary actor is really a single task or a single account depending on your view. Nothing about that feels listy to me ... May 9, 2013 at 23:42

The recordSetVar is required, because without it there is no way for the platform to know that your controller extension supports list views. Your extension also needs a constructor that has a ApexPages.StandardSetController argument

Can you clarify why don't you want to set the recordSetVar? While you might not be interacting with the list of records currently, if/when the requirements change refactoring will be much easier. Another minor bonus is it's self documenting that you are interacting with a list view.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .