0

I have a custom button that allows a user to download a CSV of the record currently displayed. To do this, I'm opening a separate Visualforce page that triggers the download by returning a page reference like so:

// Create a new page reference
    PageReference csvPage = new PageReference('/servlet/servlet.FileDownload?file=' + at.Id);

    // Set the page content to the csv file
    csvPage.getParameters().put('content', at.Body.toString());

    // Set the page title to the csv file title
    csvPage.getParameters().put('title', title);

    // Return the page reference
    return csvPage;

I would like to close the page after the action is completed, but have been unable to figure out how. Any help would be appreciated.

Visualforce Page:

    <apex:page standardController="Billing_Invoice__c" extensions="GenerateInvoiceCSV" action="{!downloadCSV}">
        <script type="text/javascript">
            window.close();
        </script>
    </apex:page>

0

You must log in to answer this question.

Browse other questions tagged .