1

I want to override my new action (button on listview) for a custom object with a link to a custom apex page. I have created an apex page with the following attributes :

<apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0"  controller="TestController">

However when I go in my custom object > Button, Links and Actions > New > Edit>Salesforce Classic Override>Visualforce page the picklist doesnt display my visualForce page.

What should I do to override my new action in the listview to link to my custom apex page ?

2

To use a Visualforce page to override a list button or create a new list button, you must use both a standardController and recordSetVar attribute. This tells Salesforce that this page understands a list of records. Your controller will now operate as an "extension" (see the extensions attribute), instead of a controller, and so will need a new constructor that accepts a single parameter, an ApexPages.StandardSetController.

<apex:page 
    showHeader="false" 
    standardStylesheets="false" 
    sidebar="false" 
    applyHtmlTag="false" 
    applyBodyTag="false" 
    docType="html-5.0"  
    standardController="Account"
    recordSetVar="accounts" 
    extensions="TestController">
  ...
</apex:page>

public class TestController {
  public TestController(ApexPages.StandardSetController controller) {
    ...
  }
  ...
}
  • 1
    The phrase "Your controller will need a new constructor to support the page." should probably be re-worded to show that the Ops controller is converted to an extension. Just a small bit of clarification. – gNerb Jan 15 at 22:32
1

Only Visualforce pages that use the standard controller for the object will appears and you can use it. extend the action by use extension attribute.

So if you need to use to page in action you can do like below:

<apex:page showHeader="false" 
           standardStylesheets="false" 
           sidebar="false" 
           applyHtmlTag="false" 
           applyBodyTag="false" 
           docType="html-5.0" 
           StandardController="objectname__c" 
           extensions="TestController">
    .........
</apex:page>

refer this link

  • Please edit your post with any clarifications. That's not what comments are for. – Adrian Larson Jan 15 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.