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
du-scodouglasdu-scodouglas 

VisualForce page not showing up in the "Content" tab when creating a button

Hi I am trying to add a list button to a layout I have, that links to a VF page I have created.

 

It works in my sandbox when I deploy all my code (the Page, Controller and Test with 100% coverage) it is all there and I can access the working VF page from /apex/Vacate (the direct URL) but when I try to pick it in the "Content" tab that shows up if you choose VisualForce page as your Content Source.

 

It exists under Develop->Pages though.

 

Any ideas?

Best Answer chosen by Admin (Salesforce Developers) 
du-scodouglasdu-scodouglas

Well, I have found the solution, but can I mark my own post as the solution to my own topic?

 

Anyones, hopefully I can, if anyone has this problem, it's cause by poor Salesforce.com platform management.

 

If you look through the documentation you will see that:

    Visualforce pages used as custom links on the home page cannot specify a controller.
    Visualforce pages used as custom buttons or links on detail pages must specify a standard controller of the same object.
    Visualforce pages used as custom list buttons must use a standard list controller of the same object.

 

These rules can be bent or broken though. Doesn't make them very good rules then eh?

 

If you want to use a custom controller with your List button (like I did) then you simply need to fool the database, one of the fields of all buttons is the "Content" field, in order to populate this with the reference to your custom controllered VF page, you need to first save it pretending to use the standard controller for the object that this button is (standardController="Account") for example. Now, link the button to your page, hit save. This will get past the asinine validation for the Content field on buttons, it now references your page. Go back to your VF page, edit it, and change to (Controller="myCustomerController"). Save. Go back to your button, make it a list button, ignore the fact that content is empty. Save.

 

Voila.

 


    All Answers

    cloudcodercloudcoder

    typically when you cant see the Visualforce page from a custom button it means your page is not using the StandardController of the object you are trying to add it to the page layout. This doesn't explain why it is working in sandbox though, but I would check there first.

     

     

    du-scodouglasdu-scodouglas

    Well, I have found the solution, but can I mark my own post as the solution to my own topic?

     

    Anyones, hopefully I can, if anyone has this problem, it's cause by poor Salesforce.com platform management.

     

    If you look through the documentation you will see that:

        Visualforce pages used as custom links on the home page cannot specify a controller.
        Visualforce pages used as custom buttons or links on detail pages must specify a standard controller of the same object.
        Visualforce pages used as custom list buttons must use a standard list controller of the same object.

     

    These rules can be bent or broken though. Doesn't make them very good rules then eh?

     

    If you want to use a custom controller with your List button (like I did) then you simply need to fool the database, one of the fields of all buttons is the "Content" field, in order to populate this with the reference to your custom controllered VF page, you need to first save it pretending to use the standard controller for the object that this button is (standardController="Account") for example. Now, link the button to your page, hit save. This will get past the asinine validation for the Content field on buttons, it now references your page. Go back to your VF page, edit it, and change to (Controller="myCustomerController"). Save. Go back to your button, make it a list button, ignore the fact that content is empty. Save.

     

    Voila.

     


      This was selected as the best answer
      aballardaballard

      You are much better off to do this right: use the expected standard controller, and add a controller extension for whatever custom processing you need. 

       

      Taking advantage of loopholes like this means you are setting your self up to have something break in a future release.  

      du-scodouglasdu-scodouglas

      How do I do this? It's for a custom object, the Account was just as an example...

       

      How do I extend Standard controllers with my own methods?

      aballardaballard

      Custom objects support standard controllers just like standard objects.   If the object is named foo, then you specify its standard controller as standardController="foo__c"   .  Extensions are specified using the extensions attribute on the page tag. 

       

      An extension controller is an apex class with a constructor that is passed the standard controller as a parameter so it can interact with it. 

       

      See the visualforce reference for examples and details. 

      du-scodouglasdu-scodouglas

      Thanks!!