0

I found many related articles on this, but the details of my situation don't seem to line up with the common queries.

I have a VF Page that I want to pull information from via the current account. So, the controller is an Apex class that gets all of that.

When I try to use this VF Page for the button (trying both Detail and List Button), it does not appear.

I tried: StandardListController = "AccountRenewal" (that's the .apxc) and get:

'Unsupported attribute standardListController in in AccountRenewal at line 1'

I tried: recordSetVar='accountrenewal' and get:

No standard controller was specified - recordSetVar cannot be used.

I try then adding StandardController="AccountRenewal" alongside that to appease it, but since that's my apex class, not a standard controller, it says it does not exist.

Suggestions?

9
  • 1
    haha, for Butter. Button* Commented Jul 20, 2016 at 14:38
  • 1
    StandardController should be sobject name (Account in your case). In that scenario, AccountRenewal should be an extension (extensions tag for apex page)
    – kurunve
    Commented Jul 20, 2016 at 14:59
  • I tried this, too. When I do StandardController = "Account", I get...Line 0 Unknown property 'AccountStandardController.doingImportObjects'. I did a quick search on the page, that whole clump of text is nowhere on the page, but this error is persistent... Commented Jul 20, 2016 at 15:05
  • so, did you add both standardController and extension to the page?
    – kurunve
    Commented Jul 20, 2016 at 15:07
  • @kurunve Extension only. The extension should inherit the standard controller so long as that's set in the class.
    – Griffin
    Commented Jul 20, 2016 at 15:08

1 Answer 1

5

Recommended reading: Difference between controller and extensions

Here you are working on writing a Controller Extension. You add this Apex Class to your page via the extensions attribute on the <apex:page> tag.


If you want to enable a Detail Button on Account, your Visualforce Page must use the standardController attribute.

<apex:page standardController="Account" extensions="AccountRenewal">

Then your class needs a constructor that accepts this standardController as a parameter.

public with sharing class AccountRenewal
{
    public AccountRenewal(ApexPages.StandardController controller)
    {
        // extension constructor logic
    }
}

If you want instead to enable a List Button on Account, your Visualforce Page must use the recordSetVar attribute in addition to the standardController attribute.

<apex:page standardController="Account" recordSetVar="accounts" extensions="AccountRenewal">

Then your class needs a constructor that accepts standardSetController as a parameter.

public with sharing class AccountRenewal
{
    public AccountRenewal(ApexPages.StandardSetController controller)
    {
        // extension constructor logic
    }
}
9
  • When I did the latter -- for List Button -- the errors went away, but still N/A when trying to select the VF Page. It is set as available in setup. The first portion -- for Detail -- gave a wonky error I don't feel is even worth posting... Commented Jul 20, 2016 at 15:24
  • If you want the button to appear when you are looking at the detail page for one record, you need a Detail Button. Does your Apex Class have the right constructor defined?
    – Adrian Larson
    Commented Jul 20, 2016 at 15:25
  • My apex class has this: public AccountRenewal(ApexPages.StandardSetController controller){ setupObjects(); } Commented Jul 20, 2016 at 15:35
  • You need to accept ApexPages.StandardController for a Detail Button. It's a different class than ApexPages.StandardSetController, which you use for a List Button. Be careful with your types.
    – Adrian Larson
    Commented Jul 20, 2016 at 15:40
  • what do you mean by this? what exactly do I do? Commented Jul 20, 2016 at 16:01

You must log in to answer this question.

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