12

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... Tia.

4 Answers 4

22

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

1
  • But recordsetvar will not be available when using customcontroller... what is the way out for that?
    – user59759
    Commented Oct 28, 2015 at 10:02
2

You have to set your visualforce page standard controller as "Risk__c" in order to be shown up under list button.

1

To be able to add Visualforce page in a 'List Button' you must have 'standard controller' for the object on which list button need to be visible.

You should create a Visualforce which have standardcontroller for "Risk__c" object to make it visible in List Buttons. And that button also needs to be created on Risk__c object

1
  • 1
    what if not using Standardcontroller and call the visualforce page from execute javascript using windows.open('/apex/yourpage',blank)? Is that possible ?
    – user59759
    Commented Oct 28, 2015 at 10:00
-1

After you have created the button, you need to put it on the page layout of you parent object Contract__c

Open the layout editor for Contract__c, scroll down to the related list for Risk__c and add the button there.

1
  • Thank you - but the problem is that when creating the list button, the visualforce page doesn't show up. I will amend my description and add a screenshot
    – Lily
    Commented Feb 18, 2015 at 13:15

You must log in to answer this question.

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