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
dmotedmote 

Custom button for VF Page

Hi,

 

I created a VF page and custom controller.  I would like to add a button on the Account Page to go to the VF Page.  When I try to create the button, I select detail page button and the content source is visualforce page, but there is nothing in the content drop down box.

 

I don't know what I am doing wrong.  Is there a setting somewhere I need to change?  I am doing this in my sandbox on Enterprise Edition.

 

Thanks,

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You'll only be able to select visualforce pages that use the standard account controller.  You can then make your custom controller an extension controller to use your custom code.

All Answers

bob_buzzardbob_buzzard

You'll only be able to select visualforce pages that use the standard account controller.  You can then make your custom controller an extension controller to use your custom code.

This was selected as the best answer
dmotedmote

Thanks so much! It works!

dmotedmote

Ok...one more quick question.

 

This is what I now have in my VF Page

 

<apex:page standardController="Account" extensions="newOpportunityController" tabStyle="Opportunity">

How do I now call the controller in my test class?

 

newOpportunityController controller = new newOpportunityController();

No longer works.

 

Thanks,

David

 

bob_buzzardbob_buzzard

As you are an extension controller, you'll need to instantiate it with the standard controller that it extends.

 

E.g.

 

 

newOpportunityController controller = new newOpportunityController(new ApexPages.StandardController(new Account()));

 

 

dmotedmote

Thanks! Now if only my test would not fail, I would be all set!