function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JGrafJGraf 

Changing a Custom Button from Detail Page Button to List Button

We have a custom button that draws into a VisualForce Page.  I want to move this button from the Detail Page and add it to the List view of it its parent record.  This would enable me to perform this action for multiple records at once.

The issue I am having is when I edit the button to change from "Detail Page Button" to "List Button".  When List Button is selected, the VisualForce Page previously used is no longer an option under Content.  Is there some coding that I need to change to allow this switch, or is there a setting on the Page or Class that need to edit?

I am a Sys Admin with just enough Coding knowledge to keep myself out of trouble but not enough to be an effective developer.

Best Answer chosen by Admin (Salesforce Developers) 
BharathimohanBharathimohan

Hi ,

 

Yes, as Khaiwong said, your page need to contain recordsetvar attribute in the <apex:page> tag as below,

 

<apex:page standardController="Opportunity" extensions="OpportunityExtn" recordSetVar="Oppties" tabStyle="Opportunity">

Once this is done, you need to use standardsetcontroller, you need to do some changes in your extension controller  :)

 

This attribute passes the selected records to your visualforce page, and hence recordsetvar is must for a page to work based on List Button.

 

 

Regards,

 

Bharathi
Salesforce For All

 

 

 

 

 

 

All Answers

BharathimohanBharathimohan

Hi,

 

If you want to have a Custom List Button in an Object which is referring to a visualforce page, then the VF page must/should have the  standardController same as that of the Object.

 

For example, if we try to create a List Button on Opportunity Object, then the visual page need to have standardController="Opportunity . Once you're done with this, you can find your VF Page as an option under Content.

 

This is because, in the List view we can select multiple records using the checkboxes and hence the page need to have standardcontroller same as that of the object in order to process it, which is must

 

You can use extension controller in your page for extending the standardController.

 

 

Please mark this post as solved, if it helps you.

 

Regards,

 

Bharathi
Salesforce For All

JGrafJGraf

Thanks for the response.

 

The page does refer to the standard controller with an extension.  This is what the first line looks like.

 

<apex:page standardController="Object Name" extensions="Extension controller" action="{!Create}">

 

Is there another reason this may not pull into the List Button?

Hengky IlawanHengky Ilawan

Hi JGraf,

 

You need to add "recordSetVar" in your apex:page tag to accept set of records.

Then, your extension class should be using StandardSetController instead of StandardController.

 

Regards,

Hengky

BharathimohanBharathimohan

Hi ,

 

Yes, as Khaiwong said, your page need to contain recordsetvar attribute in the <apex:page> tag as below,

 

<apex:page standardController="Opportunity" extensions="OpportunityExtn" recordSetVar="Oppties" tabStyle="Opportunity">

Once this is done, you need to use standardsetcontroller, you need to do some changes in your extension controller  :)

 

This attribute passes the selected records to your visualforce page, and hence recordsetvar is must for a page to work based on List Button.

 

 

Regards,

 

Bharathi
Salesforce For All

 

 

 

 

 

 

This was selected as the best answer
JGrafJGraf

Thanks guys.  While it did not completely solve my problem, it showed me where I need to go next.

John