11

I have the following VisualForce page:

<apex:page standardController="Inquery__c" 
           recordSetVar="accvar" 
           contentType="text/csv#filename.csv">

    "First Name","Last Name","Email","Qualification"

    <apex:repeat value="{!accvar}" var="a">
        <apex:outputText rendered="{!NOT(a.Download__c)}">
            {!a.First_Name__c}, {!a.Last_Name__c}, {!a.Email__c}, {!a.Quilification__c}
        </apex:outputText>
    </apex:repeat>

</apex:page>

That downloads all the records in a CSV file, That have the check box field Download__c unchecked.

How can I call this VF from a custom button on the Inquery__c custom object?

When I choose the Content Source as Visualforce Page, No content is available!

What am I doing wrong?

Thanks

23

Use a javascript for that:

window.location = 'apex/YourVisualforcePage';

This is my example of the button:

enter image description here

And the visualforce page:

<apex:page standardController="Account" recordSetVar="accounts">
    <apex:pageBlock>
        <apex:pageBlockTable value="{!accounts}" var="a">
            <apex:column value="{!a.name}"/>
            <apex:column value="{!a.CustomerPriority__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Here is the result page:

enter image description here

And here is an screenshot of the account page and the result of the click on the button:

enter image description here

Now add the button to the object page layout. Go to some of the object records page, find a lind called Edit Layout and click on it:

enter image description here

Now drag your button to the page and drop it in to the Custom buttons area, then save the layout:

enter image description here

  • What's the best practice for doing this from LEX, now that the window object is taken away and OnClick JS buttons are disabled? – Brent Bow Aug 28 '17 at 20:22
  • Yea this answer is only applicable to Salesforce Classic not LEX – compski Nov 21 '18 at 4:47
0

If you want it in Lightning experience you can do in this way.

1) Create a VF page

Download

2) Create a New Button or Link as Detail Page button , Content source as the above VF page.

3) And add the button to the custom button to the Page Layout

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.