Custom Salesforce button for Docusign giving error

2019-09-16 07:35发布

问题:

I am creating a custom docusign button on our opportunities object in salesforce and after i crafted the code i am receiving an error message "Unexpected token ~". No clue what this means. I can only hope i have something slightly off on my code. Here is the 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='';
//*************************************************//
// Modify individual options here://
// Recipient Starting Routing Order (default 1)//
RSRO = '1';
// Recipient Routing Order Sequential (default not sequential)//
RROS = '1';
// Custom Recipient List//
CRL = 'Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 1;RoutingOrder~1;SignNow~1',
Email~;FirstName~;LastName~;Role~Signer 2;RoutingOrder~2;SignNow~1,
Email~john.g@playmakercrm.com;FirstName~John;LastName~Griscavage;Role~Signer 3;RoutingOrder~3;SignNow~0,
Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 4;RoutingOrder3~;SignNow~,
Email~adam.bishop@playmakercrm.com;FirstName~Adam;LastName~Bishop;Role~Signer 5;RoutingOrder~3;SignNow~0,
Email~accounting@playmakercrm.com;FirstName~Accounting;LastName~Department;Role~Signer 6;RoutingOrder~3;SignNow~0,
Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Signer 7;RoutingOrder~3;SignNow~0,
Email~laura.mcdavid@playmakercrm.com;FirstName~Laura;LastName~McDavid;Role~Signer 8;RoutingOrder~3;SignNow~0;
// One Click Option (default edit envelope screen)//
OCO = 'Tag';
// Load Attachments (default on)//
LA = '1';
// Show Tag Button (default in config)//
STB = '1';
// Show Send Button (default in config)//
SSB = '1';
// Show Email Subject (default in config)//
SES = '1';
// Show Email Message (default in config)//
SEM = '1';
// Show Reminder/Expire (default in config)//
SRS = '1';
//********* Page Callout (Do not modify) *********//
window.location.href =
"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRC
L+"&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;
//*******************************************//

I appreciate any help someone can provide me here.

UPDATED CODE (Removed line breaks)

 {!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='';
//*************************************************//
// Modify individual options here://
RSRO = '1';RROS = '1';CRL = 'Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 1;RoutingOrder~1;SignNow~1',Email~;FirstName~;LastName~;Role~Signer 2;RoutingOrder~2;SignNow~1,Email~john.g@playmakercrm.com;FirstName~John;LastName~Griscavage;Role~Signer 3;RoutingOrder~3;SignNow~0,Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 4;RoutingOrder3~;SignNow~,Email~adam.bishop@playmakercrm.com;FirstName~Adam;LastName~Bishop;Role~Signer 5;RoutingOrder~3;SignNow~0,Email~accounting@playmakercrm.com;FirstName~Accounting;LastName~Department;Role~Signer 6;RoutingOrder~3;SignNow~0,Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Signer 7;RoutingOrder~3;SignNow~0,
Email~laura.mcdavid@playmakercrm.com;FirstName~Laura;LastName~McDavid;Role~Signer 8;RoutingOrder~3;SignNow~0;OCO = 'Tag';LA = '1';STB = '1';SSB = '1';SES = '1';SEM = '1';SRS = '1';
//********* Page Callout (Do not modify) *********//
window.location.href =
"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRC
L+"&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;
//*******************************************//

I have done just as Larry K suggested below and have updated the code. Now, the error message does not show up when i click the button. Nothing happens at all. It's almost like it is not firing.

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

//********* Option Declarations (Do not modify )*********//var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';varCCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';varCES='';var STB='';varSSB='';var SES='';var SEM='';var SRS='';var SCS ='';varRES='';//*************************************************//

// Modify individual options here://RSRO = '1';RROS = '1';CRL = 'Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 1;RoutingOrder~1;SignNow~1,Email~client@domain.com;FirstName~Client;LastName~Name;Role~Signer 2;RoutingOrder~2;SignNow~1,Email~john.g@playmakercrm.com;FirstName~John;LastName~Griscavage;Role~Signer 3;RoutingOrder~3;SignNow~0,Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 4;RoutingOrder3~;SignNow~0,Email~adam.bishop@playmakercrm.com;FirstName~Adam;LastName~Bishop;Role~Signer 5;RoutingOrder~3;SignNow~0,Email~accounting@playmakercrm.com;FirstName~Accounting;LastName~Department;Role~Signer 6;RoutingOrder~3;SignNow~0,Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Signer 7;RoutingOrder~3;SignNow~0,Email~laura.mcdavid@playmakercrm.com;FirstName~Laura;LastName~McDavid;Role~Signer 8;RoutingOrder~3;SignNow~0'; OCO = 'Tag';LA = '1';STB = '1';SSB = '1';SES = '1';SEM = '1';SRS = '1';

//********* Page Callout (Do not modify) *********//window.location.href ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.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;
//*******************************************//

UPDATED CODE YET AGAIN. Removed all recipients except one from the Custom Recipeint List. Button still does not fire. It does nothing. could it be something else i am missing in salesforce?

Here is the updated code with only one recipient:

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

//********* Option Declarations (Do not modify )*********//var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';varCCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';varCES='';var STB='';varSSB='';var SES='';var SEM='';var SRS='';var SCS ='';varRES='';//*************************************************//

// Modify individual options here://RSRO = '1';RROS = '1';CRL = 'Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 1;RoutingOrder~1;SignNow~1'; OCO = 'Tag';LA = '1';STB = '1';SSB = '1';SES = '1';SEM = '1';SRS = '1';

//********* Page Callout (Do not modify) *********//window.location.href ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.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;
//*******************************************//

回答1:

Looks like your page callouts had linebreaks (if copied direct from the DocuSign documentation they would). Try putting the variables between this:

{!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=''; //*************************************************//

// Modify individual options here://

//********* Page Callout (Do not modify) *********// window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.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; //*******************************************//



回答2:

The documentation for creating custom buttons shows that the CRL takes a string parameter. However, your CRL value is not valid because:

  1. You prematurely close the string after the Signer 1 person
  2. You have empty CRL information after the Signer 1 person
  3. You still have a hard return after the signer 7 person
  4. You don't close the string after the last person.
  5. You're missing a value for SignNow for signer 5

Also, it may be an issue that you're using an email alias for the accounting group. It would probably be better to use DocuSign Signing Groups. I don't know if that feature is supported in the Salesforce integration yet or not.

To debug, first add a return after each comma in the CRL value and check that each line (each recipient) is complete:

RSRO = '1';RROS = '1';CRL = '
Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 1;RoutingOrder~1;SignNow~1,
Email~john.g@playmakercrm.com;FirstName~John;LastName~Griscavage;Role~Signer 3;RoutingOrder~3;SignNow~0,
Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 4;RoutingOrder3~;SignNow~0,
Email~adam.bishop@playmakercrm.com;FirstName~Adam;LastName~Bishop;Role~Signer 5;RoutingOrder~3;SignNow~0,
Email~accounting@playmakercrm.com;FirstName~Accounting;LastName~Department;Role~Signer 6;RoutingOrder~3;SignNow~0,
Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Signer 7;RoutingOrder~3;SignNow~0,
Email~laura.mcdavid@playmakercrm.com;FirstName~Laura;LastName~McDavid;Role~Signer 8;RoutingOrder~3;SignNow~0
';
OCO = 'Tag';LA = '1';STB = '1';SSB = '1';SES = '1';SEM = '1';SRS = '1';

(Note the apostrophe at the start and end of the CRL value)

Next, remove the returns from the CRL value and hopefully it will work for you:

RSRO = '1';RROS = '1';CRL = 'Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 1;RoutingOrder~1;SignNow~1,Email~john.g@playmakercrm.com;FirstName~John;LastName~Griscavage;Role~Signer 3;RoutingOrder~3;SignNow~0,Email~anthony.m@playmakercrm.com;FirstName~Anthony;LastName~Miranda;Role~Signer 4;RoutingOrder3~;SignNow~0,Email~adam.bishop@playmakercrm.com;FirstName~Adam;LastName~Bishop;Role~Signer 5;RoutingOrder~3;SignNow~0,Email~accounting@playmakercrm.com;FirstName~Accounting;LastName~Department;Role~Signer 6;RoutingOrder~3;SignNow~0,Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Signer 7;RoutingOrder~3;SignNow~0,Email~laura.mcdavid@playmakercrm.com;FirstName~Laura;LastName~McDavid;Role~Signer 8;RoutingOrder~3;SignNow~0'; OCO = 'Tag';LA = '1';STB = '1';SSB = '1';SES = '1';SEM = '1';SRS = '1';