-->

Custom Salesforce (docusign) button not firing. Er

2019-09-11 14:12发布

问题:

I have built a custom button in salesforce on the opportunity object to link back to docusign and run a very specific set of actions. At first when i put the button in salesforce i would receive an error code. Now, i cannot get the button to fire at all. I ran firebug on the button and i see that there is a javascript error. I will pubslish all that i have here. You can also reference my previous question here: Custom Salesforce button for Docusign giving error - unexpected token~

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

Here is the error code i see from within firebug:

<script>
window.invokeOnClickJS_00bj0000001KavA = function(element) {
function getRecordIds(keyPrefix) { return Scontrol.prototype.getSelectedRecordIdsFromForm(element.form, keyPrefix); }
element.invokeAction = function() {
var scriptLibrary = [];
scriptLibrary.push("/apex/dsfs__DocuSign_JavaScript");
Util.loadScripts(scriptLibrary, 0, function() {
try { Util.stripCustomFunctionFromObjectPrototype(Array);eval('\r\n\r\n/\/\*\*\*\*\*\*\*\*\* 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=\'\';/\/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\//\r\n\r\n// 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\';\r\n\r\n/\/\*\*\*\*\*\*\*\*\* Page Callout (Do not modify) \*\*\*\*\*\*\*\*\*\//window.location.href =\"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID=006j000000KsS79&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;\r\n/\/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\//') } catch (e) { alert('A problem with the OnClick JavaScript for this button or link was encountered:\n\n' + (e.message ? e.message : e)) }
finally { Util.restoreCustomFunctionsToObjectPrototype(Array);}
});
};
element.invokeAction();
}
</script>

回答1:

I don't think you're ending the comments correctly. Normally, comments are on a line by themselves or use a specific end of comment sequence.

You seem to be able to have multiple lines in your button code. Are you sure that you can? I'd make it all smaller and tighter.

You also have some errors such as varCCNM instead of the correct var CCNM (You need a space after the keyword var

Note that you can have multiple Javascript var declarations in one statement. Eg:

var a=1, b=2;
// Instead of 
var a=1; var b=2;

So I would try

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

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

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';

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;

If button definitions can't contain new line characters, then just concatenate the above together onto one line.