You need to sign in to do that
Don't have an account?
Vandana Rattan
Error generating Quote PDF from JS button
I have created a List JS button in Opportunity Page > Quote Related List to generate Quote PDF for the selected Quote record. I get PdfOverlay undefined and after that a message is displayed "Cannot read Property 'dialog' of undefined. Below is my code:-
Kindly suggest some soln.
{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")} records = {!GETRECORDIDS($ObjectType.Quote)}; alert('records > ' + records); var selectedRecords = [records]; alert('selectedRecords>' + selectedRecords); var pdfOverlay = QuotePDFPreview.quotePDFObjs['quotePDFOverlay']; alert('pdfOverlay > ' + pdfOverlay); pdfOverlay.dialog.buttonContents = '<input value=\"Save to Quote\" class=\"btn\" name=\"save\" onclick=\"QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'0\',\'0\');\" title=\"Save to Quote\" type=\"button\" /><input value=\"Save and Email Quote\" class=\"btn\" name=\"saveAndEmail\" onclick=\"QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'1\');\" title=\"Save and Email Quote\" type=\"button\" /><input value=\"Cancel\" class=\"btn\" name=\"cancel\" onclick=\"QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').close();\" title=\"Cancel\" type=\"button\" />'; //change this to use the correct template for your business/environment!! pdfOverlay.summlid = '0EH90000000Gdtu'; pdfOverlay.setSavable(true); //change this to use the quote id pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!Quote.Id}','quote/quoteTemplateHeaderData.apexp?id={!Quote.Id}'); pdfOverlay.display();
Kindly suggest some soln.
Just copy this and it should work.
var pdfOverlay = QuotePDFPreview.quotePDFObjs['quotePDFOverlay'];
pdfOverlay.dialog.buttonContents = '<input value=\"Save to Quote\" class="btn" name="save" onclick="QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'0\',\'0\');" title="Save to Quote" type="button" /><input value="Save and Email Quote" class="btn" name="saveAndEmail" onclick="QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'1\');" title="Save and Email Quote" type="button" /><input value="Cancel" class="btn" name="cancel" onclick="QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').close();" title="Cancel" type="button"/>';
pdfOverlay.summlid = 'Your Template ID Here';
pdfOverlay.setSavable(true);
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!Quote.Id}','quote/quoteTemplateHeaderData.apexp?id={!Quote.Id}');
pdfOverlay.display();
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!Quote.Id}
https://kabtutorial-developer-edition.my.salesforce.com/0Q080000000H74E
the quote id is : 0Q080000000H74E
If use a hard coded Quote.Id I suppose that it will not work for all the other Quotes.
I need to create a custom button which is using a predefined template.
see below the code that I used from this post.
but I got the following error:
by the way did you manage to replicate this custom button on your sandbox?
Thanks in advance
Dimitri
{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
var pdfOverlay = QuotePDFPreview.quotePDFObjs['quotePDFOverlay'];
pdfOverlay.dialog.buttonContents = '<input value=\"Save to Quote\" class="btn" name="save" onclick="QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'0\',\'0\');" title="Save to Quote" type="button" /><input value="Save and Email Quote" class="btn" name="saveAndEmail" onclick="QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'1\');" title="Save and Email Quote" type="button" /><input value="Cancel" class="btn" name="cancel" onclick="QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').close();" title="Cancel" type="button"/>';
pdfOverlay.summlid = "0EHb0000000VEWc";
pdfOverlay.setSavable(true);
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!Quote.Id}','quote/quoteTemplateHeaderData.apexp?id="0Q0b0000000JNzn"');
pdfOverlay.display();