3

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 Answers 2

3

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
  • 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
    Commented Jan 15, 2019 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

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

You must log in to answer this question.

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