0

Getting the following error when clicking a custom button I created: A problem with the OnClick JavaScript for this button or link was encountered: Invalid or unexpected token

My code:

{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")} 

//********* Option Declarations (Do not modify )*********// 
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var 
CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var 
CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var 
SRS='';var SCS ='';var RES=''; 
//*************************************************// 

var CES=’Please sign this [Company]’; 
var LA='0'; 
var DST='213eba34-766e-41e9-9ca0-c79f9aa094ed'; 

//********* Page Callout (Do not modify) *********// 
window.location.href = 
"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID= 
{!Lead.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+" 
&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+" 
&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+" 
&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+" 
&SRS="+SRS+"&SCS="+SCS+"&RES="+RES; 
//*******************************************//

Any advice greatly appreciated.

1

I think the error is in line:

var CES = ’Please sign this[Company]’;

The inverted comma used is different. It should be

var CES = 'Please sign this[Company]';

Apart from the above error, there were ENTER presses in the last line which were causing the issues. The below code works fine

{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}

var RC = '';
var RSL = '';
var RSRO = '';
var RROS = '';
var CCRM = '';
var CCTM = '';
var
    CCNM = '';
var CRCL = '';
var CRL = '';
var OCO = '';
var DST = '';
var LA = '';
var
    CEM = '';
var CES = '';
var STB = '';
var SSB = '';
var SES = '';
var SEM = '';
var
    SRS = '';
var SCS = '';
var RES = '';

var CES = 'Please sign this [Company]';
var LA = '0';
var DST = '213eba34-766e-41e9-9ca0-c79f9aa094ed';

window.location.href =
    "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Lead.Id}&RC=" + RC + "&RSL=" + RSL + "&RSRO=" + RSRO + "&RROS=" + RROS + "&CCRM=" + CCRM + "&CCTM=" + CCTM + "&CRCL=" + CRCL + "&CRL=" + CRL + "&OCO=" + OCO + "&DST=" + DST + "&CCNM=" + CCNM + "&LA=" + LA + "&CEM=" + CEM + "&CES=" + CES + "&SRS=" + SRS + "&STB=" + STB + "&SSB=" + SSB + "&SES=" + SES + "&SEM=" + SEM + "&SRS=" + SRS + "&SCS=" + SCS + "&RES=" + RES;
| improve this answer | |
  • Thanks, Manjit, but I copied/pasted your code and still got the same error. – Brooks Bruce Jan 12 '17 at 17:35
  • Actually you have to change one line. I have not added the correction in the code. Please look at the last 4 line. The code I wrote is only formatted version of your code – manjit5190 Jan 12 '17 at 18:00
  • I meant that I copied/pasted the one line of corrected code and updated my code with it: var CES = 'Please sign this[Company]' Still getting the same error, though. Thanks for trying to help! – Brooks Bruce Jan 12 '17 at 18:04
  • 1
    It means that an enter(\r\n) was pressed after this line "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID= which was causing the error. – manjit5190 Jan 12 '17 at 19:40
  • 1
    Hover over the button and then right click and select inspect element. Just Above the button you will find a script tag. Expant it and see what is written in eval() function. You may mark this as accepted if it solved your problem. – manjit5190 Jan 12 '17 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.