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* – Natalie Spatharakis Jul 20 '16 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 Jul 20 '16 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... – Natalie Spatharakis Jul 20 '16 at 15:05
  • so, did you add both standardController and extension to the page? – kurunve Jul 20 '16 at 15:07
  • @kurunve Extension only. The extension should inherit the standard controller so long as that's set in the class. – Griffin Jul 20 '16 at 15:08
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... – Natalie Spatharakis Jul 20 '16 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 Jul 20 '16 at 15:25
  • My apex class has this: public AccountRenewal(ApexPages.StandardSetController controller){ setupObjects(); } – Natalie Spatharakis Jul 20 '16 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 Jul 20 '16 at 15:40
  • what do you mean by this? what exactly do I do? – Natalie Spatharakis Jul 20 '16 at 16:01

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.