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 Answer 1

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;
9
  • Thanks, Manjit, but I copied/pasted your code and still got the same error. Commented Jan 12, 2017 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 Commented Jan 12, 2017 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! Commented Jan 12, 2017 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. Commented Jan 12, 2017 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. Commented Jan 12, 2017 at 19:50

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.