List button doesn’t see Visualforce page

I have the parent object Contract__c and the child object Risk__c. I have created a visualforce page for Risk__c and now I want to create a list button, which shows up on the related list on Contract__c, that opens this visualforce page. The Visualforce page shows up when I select Detail button, but when I try to create a list button, it doesn’t show up.

So, to explain in more detail. The Visualforce page called testpage has Risk__c as the standard controller.

I want to create a List Button, but I don’t have the option to select a visualforce page:
List Button

When I select Detail Button though, I have the option to select that visualforce page:
Detail Button

I am confused, and I have no idea how I can invoke that visualforce page from the related list on Contract__c otherwise.

I am not sure what I am doing wrong…


I ran into the same issue and here’s the answer:

A visualforce page can be available for either a page view (that gets passed one ID) or a list view (that gets passed a list of 0 or more records).

Here’s what you have, and it works for the page view, and the ID of the individual record is passed as the page’s id parameter. This doesn’t make sense on the list view, because you’d have a list of many different IDs, so they can’t all be the id parameter:

<apex:page standardController="Risk__c">

Here’s what you can add to change it to be available on a list, :

<apex:page standardController="Risk__c" recordSetVar="risks">

From Salesforce:

The component also has a recordSetVar attribute. We use this attribute
to change the standardcontroller so that it accommodates a set of
records rather than a single record.

In other words, it will pass a list of records, that’s why you can select “Display Checkboxes (for Multi-Record Selection)” when you’re configuring the button.

So if you want to use the visualforce page exclusively for the page view button/link or exclusively for the list view button, that’s your solution.

Another solution is to use a button with URL as the type, and link to your page, but then you won’t get the list of IDs, but you could pass the ID (or another value) from your parent object, Contract__c.

Here’s an example of building out a page for a list button from Salesforce

Source : Link , Question Author : Lily , Answer Author : SecondJon

Leave a Comment