un-terminated string error

I'm using JavaScript to within a custom button in Salesforce, but I'm getting an un-terminated string literal in the following string:
 
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

var newRecords = [];
var appObj = new sforce.SObject("Application__c");
appObj.Id = "{!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}";
appObj.eContract__c = true;
newRecords.push(appObj);

window.location.href = encodeURI('
https://composer.congamerge.com
?sessionId={!JSENCODE(API.Session_ID)}
&serverUrl={!JSENCODE(API.Partner_Server_URL_80)}
&id={!JSENCODE(AFC_Contract_Shell__c.Id)}
&QueryID=[BusinessAccount]a1Qa0000001uKKK,
[PrincipalContact]a1Qa0000001uKKO,
[FloorplanFee]a1Qa0000001uKKR,
[NumberofCurtailments]a1Qa0000001uKKM,
[Interest]a1Qa0000001uKKP,
[CurtailmentFee]a1Qa0000001uKKN,
[Principal]a1Qa0000001uKKH,
[BusType]a1Qa0000001uKKJ,
[DateInWords]a1Qa0000001uKKQ,
[CurtailmentTermWord]a1Qa0000001uKKL,
[PrincipalSum]a1Qa0000001uKKI,
[BusinessName]a1Qa0000001uKKF,
[GuarantorSig]a4G13000000LP1o?pv0={!JSENCODE(AFC_Contract_Shell__c.Id)},
[PrimarySig]a4G13000000LP1y?pv0={!JSENCODE(AFC_Contract_Shell__c.Id)}
&ReportID=[PContacts]00O13000008jhuD?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}


&LG0=0
&LG1=Contract+Generated
&LG4=1
&SelectTemplates=1
&Templategroup={!JSENCODE(CASE(AFC_Contract_Shell__c.Name,
"US Contract", "USAFCeContracts",
"US Amendment", "USAFCeContracts",
"California Contract", "CALAFCeContracts",
"California Amendment", "CALAFCeContracts",
"Canada Contract", "CANAFCeContracts",
"Canada Amendment", "CANAFCeContracts",
"AFC Credit"))}


&DocuSignVisible=1
&DS7=7
&DocuSignTag=1
&DocuSignEmailSubject={!JSENCODE(AFC_Contract_Shell__c.AFC_Dealer_ID__c)}+Your+AFC+Contract+is+Ready

&QVar0ID=a4G13000000LPCO?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}
&QVar1ID=a4G13000000LPCP?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}
&QVar2ID=a4G13000000LPCQ?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}
&QVar3ID=a4G13000000LPCR?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}

&DocuSignR1Id={Qvar0}
&DocuSignR1Type=Signer
&DocuSignR1Role=Signer+1
&DocuSignR1RoutingOrder=2
&DocuSignR1AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}
&DocuSignR1IdCheck=1
&DocuSignR1IdCheckType=RSA

&DocuSignR2Id={Qvar1}
&DocuSignR2Type=Signer
&DocuSignR2Role=Signer+2
&DocuSignR2RoutingOrder=2
&DocuSignR2AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}
&DocuSignR2IdCheck=1
&DocuSignR2IdCheckType=RSA

&DocuSignR3Id={Qvar2}
&DocuSignR3Type=Signer
&DocuSignR3Role=Signer+3
&DocuSignR3RoutingOrder=2
&DocuSignR3AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}
&DocuSignR3IdCheck=1
&DocuSignR3IdCheckType=RSA

&DocuSignR4Id={Qvar3}
&DocuSignR4Type=Signer
&DocuSignR4Role=Signer+4
&DocuSignR4RoutingOrder=2
&DocuSignR4AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}
&DocuSignR4IdCheck=1
&DocuSignR4IdCheckType=RSA

&DocusignR5Id={!JSENCODE(AFC_Contract_Shell__c.AFC_eContract_Role__c)}
&DocuSignR5Type=Approver
&DocuSignR5Role=Approver+5
&DocuSignR5RoutingOrder=1
&DocuSignR5IdCheck=0

&DocusignR6Id={!JSENCODE(AFC_Contract_Shell__c.AFC_Branch_Console_Owner__c)}
&DocuSignR6Type=Approver
&DocuSignR6Role=Approver+6
&DocuSignR6RoutingOrder=6
&DocuSignR6IdCheck=0
');

Open in new window


I've added encodeURI to the full URL and I've wrapped all merge field expressions with JSENCODE. I'm still getting un-terminated string error.

Any help is appreciated.
Thanks.
-Dman100-Software ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mukesh YadavFull Stack DeveloperCommented:
To correct this error
Add the closing quotation mark to the end of the string.
0
-Dman100-Software ConsultantAuthor Commented:
I have a closing single quote at the end of the string.  Do you mean I need another one? I'm getting a syntax error if I add another single quote? Please explain?
0
Mukesh YadavFull Stack DeveloperCommented:
Can you share the code you are getting in browser?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Julian HansenCommented:
You are breaking of your string is not legal you either have to terminate the line with a '\' or close the quote and put a +  open quote on the next line

Example

var x = 'This is a test\
to see if this works';
var y = 'This is another test'
+ ' to see if this works';

Open in new window

0
Julian HansenCommented:
Amending your code should look like this
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

var newRecords = [];
var appObj = new sforce.SObject("Application__c");
appObj.Id = "{!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}";
appObj.eContract__c = true;
newRecords.push(appObj);

window.location.href = encodeURI('\
https://composer.congamerge.com\
?sessionId={!JSENCODE(API.Session_ID)}\
&serverUrl={!JSENCODE(API.Partner_Server_URL_80)}\
&id={!JSENCODE(AFC_Contract_Shell__c.Id)}\
&QueryID=[BusinessAccount]a1Qa0000001uKKK,\
[PrincipalContact]a1Qa0000001uKKO,\
[FloorplanFee]a1Qa0000001uKKR,\
[NumberofCurtailments]a1Qa0000001uKKM,\
[Interest]a1Qa0000001uKKP,\
[CurtailmentFee]a1Qa0000001uKKN,\
[Principal]a1Qa0000001uKKH,\
[BusType]a1Qa0000001uKKJ,\
[DateInWords]a1Qa0000001uKKQ,\
[CurtailmentTermWord]a1Qa0000001uKKL,\
[PrincipalSum]a1Qa0000001uKKI,\
[BusinessName]a1Qa0000001uKKF,\
[GuarantorSig]a4G13000000LP1o?pv0={!JSENCODE(AFC_Contract_Shell__c.Id)},\
[PrimarySig]a4G13000000LP1y?pv0={!JSENCODE(AFC_Contract_Shell__c.Id)}\
&ReportID=[PContacts]00O13000008jhuD?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}\
\
\
&LG0=0\
&LG1=Contract+Generated\
&LG4=1\
&SelectTemplates=1\
&Templategroup={!JSENCODE(CASE(AFC_Contract_Shell__c.Name,\
"US Contract", "USAFCeContracts",\
"US Amendment", "USAFCeContracts",\
"California Contract", "CALAFCeContracts",\
"California Amendment", "CALAFCeContracts",\
"Canada Contract", "CANAFCeContracts",\
"Canada Amendment", "CANAFCeContracts",\
"AFC Credit"))}\
\
\
&DocuSignVisible=1\
&DS7=7\
&DocuSignTag=1\
&DocuSignEmailSubject={!JSENCODE(AFC_Contract_Shell__c.AFC_Dealer_ID__c)}+Your+AFC+Contract+is+Ready\
\
&QVar0ID=a4G13000000LPCO?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}\
&QVar1ID=a4G13000000LPCP?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}\
&QVar2ID=a4G13000000LPCQ?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}\
&QVar3ID=a4G13000000LPCR?pv0={!JSENCODE(AFC_Contract_Shell__c.ApplicationId__c)}\
\
&DocuSignR1Id={Qvar0}\
&DocuSignR1Type=Signer\
&DocuSignR1Role=Signer+1\
&DocuSignR1RoutingOrder=2\
&DocuSignR1AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}\
&DocuSignR1IdCheck=1\
&DocuSignR1IdCheckType=RSA\
\
&DocuSignR2Id={Qvar1}\
&DocuSignR2Type=Signer\
&DocuSignR2Role=Signer+2\
&DocuSignR2RoutingOrder=2\
&DocuSignR2AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}\
&DocuSignR2IdCheck=1\
&DocuSignR2IdCheckType=RSA\
\
&DocuSignR3Id={Qvar2}\
&DocuSignR3Type=Signer\
&DocuSignR3Role=Signer+3\
&DocuSignR3RoutingOrder=2\
&DocuSignR3AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}\
&DocuSignR3IdCheck=1\
&DocuSignR3IdCheckType=RSA\
\
&DocuSignR4Id={Qvar3}\
&DocuSignR4Type=Signer\
&DocuSignR4Role=Signer+4\
&DocuSignR4RoutingOrder=2\
&DocuSignR4AccessCode={!JSENCODE(AFC_Contract_Shell__c.eContract_Access_Code__c)}\
&DocuSignR4IdCheck=1\
&DocuSignR4IdCheckType=RSA\
\
&DocusignR5Id={!JSENCODE(AFC_Contract_Shell__c.AFC_eContract_Role__c)}\
&DocuSignR5Type=Approver\
&DocuSignR5Role=Approver+5\
&DocuSignR5RoutingOrder=1\
&DocuSignR5IdCheck=0\
\
&DocusignR6Id={!JSENCODE(AFC_Contract_Shell__c.AFC_Branch_Console_Owner__c)}\
&DocuSignR6Type=Approver\
&DocuSignR6Role=Approver+6\
&DocuSignR6RoutingOrder=6\
&DocuSignR6IdCheck=0\
');

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
-Dman100-Software ConsultantAuthor Commented:
Thank you for your help!!
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.