+ Start a Discussion
Bailey RuddBailey Rudd 

Custom OnClick JavaScript button unexpected results on 'Save to Quote'

I have a custom JavaScript button on Quote page that mimics Salesforce's standard PDF overlay that is used after you select a quote template, except with our custom button it assigns the quote template ID automatically and renders the quote preview overlay with 1 click.  It's been working great until recently, the 'Save to Quote' command is not working. When you click - nothing happens. All the other buttons work as expected.  Anyone care to look at my code and offer suggestions would be appreciated! 
{!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="0EHo0000000itAg";pdfOverlay.setSavable(true);pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');pdfOverlay.display();


 
Nayana KNayana K
{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")}

/* add try catch block for debugging purpose and check if any exception alert is displayed*/
try
{

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="0EHo0000000itAg";
pdfOverlay.setSavable(true);
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');
pdfOverlay.display();
}
catch(e)
{
   alert('Exception '+e);
}

 
Bailey RuddBailey Rudd
I added the try catch block as suggested. Because this is my first custom button, I'm unfamiliar with the expected behavior on clicking save (PDFOverlay.setSavable (true)) after adding the try catch block. Show I look at logs? Or would I get a popup like alert?
Nayana KNayana K
You should get exception alert if there is any exception
Bailey RuddBailey Rudd
Unfortunately I did not get any alerts.