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

Attachment preview

Dear Developers,


Is it possible to do a preview of the attachment file?


I want to have preview of the VF page am rendering as PDF and sending it as an attachment in email, is it possible? If so then how?


Regards and Thanks in advance




You should be able to simply open a popup window and pass the URL of the PDF.


How are you firing the email send?  Does the user click a button on another page?


The email is sent from a VF page " MaintenanceReserveInvoice"  where the user enters the address and clicks the button , the pdf attachment page is another VF  page "invoicegenerator"


Thanks and regards...


You should then be able to specify an onclick javascript function that opens the invoicegenerator page in a popup window.


Can 2 windows be opened at the same time on a mouse click?

The page where the user sets the email add and the page were the PDF is?


Thanks and Regards



While I can't see any reason why that wouldn't work, its not something I've done myself so I can't say for sure that it would.



How would the script likely be?




This would open the page were the user inputs the add, how can the other window  the PDF page included? Any help would be appreciated


Thanks and regards



Could it be done using the Visualforce Component,  is there a way it can used with in a controller?



A controller won't be able to open a window on the browser, that has to be done client side.


If you are using a commandbutton, then the following snippet opens a window as well as submitting the form:



<apex:commandButton value="Submit" onclick="'', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />






How's the address to the pdf page passed onto onclick, the apex page address with the ID?


something like this



Thanks and regards


P.S Sorry if my question is silly, but I still need to learn ^__^


In the commandbutton example, the URL is highlighted in red:



<apex:commandButton value="Submit" onclick="'', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />


So in your case you'd have something like:



<apex:commandButton value="Submit" onclick="'/apex/InvoiceGenerator?id=<id goes here>', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />






Id value is not valid for the Utilization_Report__c standard controller

This is the error that's coming up when trying to access the ID! Could it be that because there is no ID field in the Utilization_Report__c object?


Thanks and regards


That looks like you have used the text literal rather than merge field.


Does your command button look like this:



<apex:commandButton value="Submit" onclick="'/apex/InvoiceGenerator?', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />

 If so, change to:


<apex:commandButton value="Submit" onclick="'/apex/InvoiceGenerator?id={!}', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />



<apex:commandButton value="Preview"     onclick="'/apex/InvoiceGenerator?id={!}', 'Popup',                         'height=500,width=600,left=100,top=100,resizable=no,     scrollbars=yes,toolbar=no,status=no');" />


I found out that there was a space between the equal sign and the merge field that generates a different ID each time the preview button was clicked, I guess I will have be more alret and take care of those minute details..


Thanks alot for the great help and helping me thru





Glad to see that you got there.