自定义Salesforce(docusign)按钮未触发。提供错误代码

时间:2016-07-07 21:56:39

标签: salesforce docusignapi

我在机会对象的salesforce中构建了一个自定义按钮,以链接回docusign并运行一组非常具体的操作。首先,当我将按钮放在salesforce中时,我会收到错误代码。现在,我根本无法触发按钮。我在按钮上运行了firebug,我发现有一个javascript错误。我将发布我在这里的所有内容。您还可以在此处参考我之前的问题: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;
//*******************************************//

这是我在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 个答案:

答案 0 :(得分:0)

我认为你没有正确地结束评论。通常情况下,评论单独排在一行或使用评论序列的特定结尾。

您似乎可以在按钮代码中包含多行。你确定可以吗?我会让它变得更小更紧凑。

您还有一些错误,例如varCCNM而不是正确的var CCNM(关键字var

后需要一个空格

请注意,您可以在一个语句中包含多个Javascript var声明。例如:

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

所以我会尝试

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

如果按钮定义不能包含换行符,则只需将上述内容连接在一行即可。