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
AbAb 

Custom button opening VF page

Hello,

I am looking to create a cutom button, like below but i get below error. I have few visualforce pages but i cant see them.
User-added image
Best Answer chosen by Ab
Tugce SirinTugce Sirin
Your visualforce page needs to have standardController of object that will have the custom button you're creating. Otherwise you can't see the visualforce page in content field thus can not create the button.

For instance if you want to create custom button for Account object your vf page should start like this;
 
<apex:page standardController="Account" extensions="yourController">


And your controller class constructor should look like this;
 
public yourController(ApexPages.StandardController ctrl){
//constructor code
}

 

All Answers

Tugce SirinTugce Sirin
Your visualforce page needs to have standardController of object that will have the custom button you're creating. Otherwise you can't see the visualforce page in content field thus can not create the button.

For instance if you want to create custom button for Account object your vf page should start like this;
 
<apex:page standardController="Account" extensions="yourController">


And your controller class constructor should look like this;
 
public yourController(ApexPages.StandardController ctrl){
//constructor code
}

 
This was selected as the best answer
AbAb
My object is not standard, it is custom object, in this case what modifications, should i make
Tugce SirinTugce Sirin
It doesn't matter if an object is standard or custom. Only custom objects have __c appendix in their api name. You should just change the first line on your VF to this
 
<apex:page standardController="YourCustomObject__c" extensions="yourController">
And change your controller's constructor method to this;
 
public yourController(ApexPages.StandardController ctrl){
More info: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm