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
Matthew AllenMatthew Allen 

Detail Page button to load VF page?

Hi,

Below is my VF page, but it isn;t available to me to direct a Detail Page button to it - can anyone help as to why?
 
<apex:page standardController="Custom_Object__c" recordSetVar="Opportunities" showHeader="false" sidebar="false">
   <apex:sectionHeader title="eVA Qualification Form Edit" subtitle="New eVA Qualification Form"/>

    <apex:form>
        <apex:pageBlock title="eVA Qualification Form Edit" mode="edit">
             <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
             </apex:pageBlockButtons>
                        
            <apex:pageBlockSection title="Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Opportunity__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.OwnerId}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Website_URL__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Website_Visits_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Existing_SAV_User__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Stock_Level__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Sales_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Part_Exchange__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Number_of_Part_Ex_valuations_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.How_do_they_know_this__c}" required="false"/>
                <apex:inputField value="{!Custom_Object__c.Do_they_have_a_valuation_CAP_license__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.What_are_thier_Business_objectives__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Consumer_Journey_thoughts__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Additional_Information__c}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
            <apex:pageBlockSection title="System Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Name}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
        </apex:pageBlock>
    </apex:form>
   

</apex:page>

 
ShirishaShirisha (Salesforce Developers) 
Hi Matthew,

Greetings!

Can you please try by adding the below in the first line of the visualforce page to see,if it allows you to use the VF on the detail page button:

standardStylesheets="true"

Reference:https://developer.salesforce.com/forums/?id=9060G0000005jKlQAI

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Dushyant SonwarDushyant Sonwar
Hi Matthew,

Try adding apex;pagemessages in your vf code.
<apex:page standardController="Custom_Object__c" recordSetVar="Opportunities" showHeader="false" sidebar="false">
   <apex:sectionHeader title="eVA Qualification Form Edit" subtitle="New eVA Qualification Form"/>

    <apex:form>
        <apex:pageBlock title="eVA Qualification Form Edit" mode="edit">
            <apex:pagemessages id="pg"/>
             <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
             </apex:pageBlockButtons>
                        
            <apex:pageBlockSection title="Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Opportunity__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.OwnerId}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Website_URL__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Website_Visits_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Existing_SAV_User__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Stock_Level__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Sales_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Part_Exchange__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Number_of_Part_Ex_valuations_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.How_do_they_know_this__c}" required="false"/>
                <apex:inputField value="{!Custom_Object__c.Do_they_have_a_valuation_CAP_license__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.What_are_thier_Business_objectives__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Consumer_Journey_thoughts__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Additional_Information__c}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
            <apex:pageBlockSection title="System Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Name}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
        </apex:pageBlock>
    </apex:form>
   

</apex:page>

Please let us know if it doesn't help.
Matthew AllenMatthew Allen
Thank you both for trying, but neither solution worked. My VF page is still not available from a button.
Dushyant SonwarDushyant Sonwar
Hi Matthew,

Remove recordSetVar="Opportunities"  atrribute if you want to make it available from button.
<apex:page standardController="Custom_Object__c" showHeader="false" sidebar="false">
   <apex:sectionHeader title="eVA Qualification Form Edit" subtitle="New eVA Qualification Form"/>

    <apex:form>
        <apex:pageBlock title="eVA Qualification Form Edit" mode="edit">
            <apex:pagemessages id="pg"/>
             <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
             </apex:pageBlockButtons>
                        
            <apex:pageBlockSection title="Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Opportunity__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.OwnerId}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Website_URL__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Website_Visits_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Existing_SAV_User__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Stock_Level__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Sales_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Part_Exchange__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Number_of_Part_Ex_valuations_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.How_do_they_know_this__c}" required="false"/>
                <apex:inputField value="{!Custom_Object__c.Do_they_have_a_valuation_CAP_license__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.What_are_thier_Business_objectives__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Consumer_Journey_thoughts__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Additional_Information__c}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
            <apex:pageBlockSection title="System Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Name}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
        </apex:pageBlock>
    </apex:form>
   

</apex:page>



Let us know if it doesn't work.
Matthew AllenMatthew Allen
Thank you all for your help so far, but it hasn;t worked.... I think it could be down to some important information I missed out....

I want to load this VF page from the Opportunity Object. SO I want it to sit on the Opportunity page layout, and when pressed, it create this custom object record.

Sorry, I wasn't clear at all.
Dushyant SonwarDushyant Sonwar
Matthew,

You can use your vf page by creating custom button on opportunity and Choose Content Source as URL


User-added image

Add the below url
/apex/[yourpagename]

and you wil be able to use it on opportunity object.

 
Dushyant SonwarDushyant Sonwar
Your page right now is not visible it on VF Page select option list as your standard controller is Cusom_Object__c and it must be opportunity in order to show that page on the select option.

If you use standard controller as opportunity then you have to use extension to add save functionality of your custom object through apex code.