+ Start a Discussion
Bailey RuddBailey Rudd 

A problem with the OnClick JavaScript for this button or link was encountered: Unexpected token ILLEGAL

Hello,

I have created a custom button on the Quote layout that selects a certain template automatically. Except I'm receiving this error when clicked: 

A problem with the OnClick JavaScript for this button or link was encountered:

Unexpected token ILLEGAL

Here is the code:
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="0EHo0000001E982";
pdfOverlay.setSavable(true);
pdfOverlay.setContents('\quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');
pdfOverlay.display();

 
Best Answer chosen by Bailey Rudd
Temoc MunozTemoc Munoz
The error is related to a malformed URL.

Can you try changing this 

pdfOverlay.setContents('\quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');

to this
 pdfOverlay.setContents('/quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');

or this
 
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');

All Answers

Temoc MunozTemoc Munoz
Hi Bailey.

Could it be that you're missing a single quote before the semi-colon at line 07?

.... title="Cancel" type="button"/>';
Bailey RuddBailey Rudd

Same error after adding a single quote to line 07 before semi-colon. Any other suggestions?
 
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="0EHo0000001E982";
pdfOverlay.setSavable(true);
pdfOverlay.setContents('\quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');
pdfOverlay.display();

 
Temoc MunozTemoc Munoz
I tried your example and this is a next line issue in Salesforce. Can you try removing the extra return line in your code?

For example go to the beginning of line 02 and hit the backspace key. Then press the space bar to remove the next line. Do this for all lines.

 
Bailey RuddBailey Rudd
Getting closer! It now renders the overlay, but it's not recognizing something. I tried changing summlid and still not working.
I get the summlid ID by the quote templates edit page in the URL, correct? Not sure what it doesn't like here....


 User-added image
Temoc MunozTemoc Munoz
The error is related to a malformed URL.

Can you try changing this 

pdfOverlay.setContents('\quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');

to this
 pdfOverlay.setContents('/quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');

or this
 
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id={!(Quote.Id)}','/quote/quoteTemplateHeaderData.apexp?id={!(Quote.Id)}');
This was selected as the best answer
Bailey RuddBailey Rudd
3rd choice worked perfect! Thank You!
Temoc MunozTemoc Munoz
Awesome!!

I'm glad it worked.