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
Amita TatarAmita Tatar 

not able to add a vf page in list button

Hi all,

I have a requirement where i want to create a list button and give Visualforce page as a content. But when i do this, i am not able to select vf page as a content while creation of this button. Why is it so? Can anyone help me out here.

Regards,
Amita Tatar
Prithviraj_ChavanPrithviraj_Chavan
Hi Amita Tatar,

I think you should add standard controller to your page so you will be able to select page.
can you paste your code so I can help you..
 
Lokesh KumarLokesh Kumar
Hi Amita Please refer the below code snippet and the article for the same.
 
<apex:page standardController="Opportunity" recordSetVar="opportunities" tabStyle="Opportunity" extensions="tenPageSizeExt">
    <apex:form >
        <apex:pageBlock  title="Edit Stage and Close Date" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!selected}" var="opp">
                <apex:column value="{!opp.name}"/>
                <apex:column headerValue="Stage">
                    <apex:inputField value="{!opp.stageName}"/>
                </apex:column>
                <apex:column headerValue="Close Date">
                    <apex:inputField value="{!opp.closeDate}"/>
                </apex:column>
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
    </apex:page>
Article : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_custom_button.htm

Thanks
Lokesh
 
Amita TatarAmita Tatar
Actually i have created a custom list  button and in that i want to give Visualforce page as content source
Prithviraj_ChavanPrithviraj_Chavan
Hi Amita,
Follow this image
just redirect to your visual force page and you can also append record Id to your vf page
Amita TatarAmita Tatar
Hi Prithviraj,

I have done the following thing:
window.location.href = "/apex/InvoicePrint?id={!Invoice__c.Id}"

But it says invalid id
Prithviraj_ChavanPrithviraj_Chavan
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")} 
var c = new sforce.SObject("InvoiceObject__c"); 
c.id ="{!InvoiceObject__c.Id }";
var url='yourpage/{!c.id}';
window.location.href = url;
you must include connection.js and apex.js