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
SjaleelSjaleel 

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

 

 

bob_buzzardbob_buzzard

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?

SjaleelSjaleel

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...

bob_buzzardbob_buzzard

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

SjaleelSjaleel

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

 

bob_buzzardbob_buzzard

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.

 

SjaleelSjaleel

How would the script likely be?

 

navigateToUrl('/apex/MaintenanceReserveInvoice?id={!Utilization_Report__c.Id}')

 

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

 

SjaleelSjaleel

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

 

bob_buzzardbob_buzzard

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="window.open('http://www.google.com', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />

 

 

 

 

SjaleelSjaleel

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

 

something like this

"apex/invoicegenerator?id="

 

Thanks and regards

 

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

bob_buzzardbob_buzzard

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

 

 

<apex:commandButton value="Submit" onclick="window.open('http://www.google.com', '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="window.open('/apex/InvoiceGenerator?id=<id goes here>', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />

 

 

 

 

SjaleelSjaleel

Id value Utilization_Report__c.id 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

bob_buzzardbob_buzzard

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="window.open('/apex/InvoiceGenerator?id=Utilization_Report__c.id', '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="window.open('/apex/InvoiceGenerator?id={!Utilization_Report__c.id}', 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');" />

 

SjaleelSjaleel

<apex:commandButton value="Preview"     onclick="window.open('/apex/InvoiceGenerator?id={!UR.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

 

Regards

SAjaleel

bob_buzzardbob_buzzard

Glad to see that you got there.