我在Salesforce中创建了DocuSign自定义按钮。在运行DocuSign按钮逻辑之前尝试在不满足某些字段值时添加错误。
我想要的条件是,商机阶段的选择列表值不等于"已关闭赢了"然后触发错误消息。否则,执行DocuSign自定义按钮。
我对javascript很新,刚刚开始学习,所以我为基本问题道歉并感谢反馈。
我目前的脚本如下:
{!REQUIRESCRIPT("/apex/DocuSign_JavaScript")}
var oppStage = "Closed Won";
var error;
{
if ({!Opportunity.StageName}!=oppStage)
{
error = "Unable to send envelope. Opportunity Stage does not equal Closed won.";
}
else {
//********* 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='';
//*************************************************//
CES="Hello World";
CRL='FirstName~{!URLENCODE(User.FirstName)};LastName~{!URLENCODE(User.LastName)};Email~{!URLENCODE(User.Email)};Role~OppOwner;RoutingOrder~2,LoadDefaultContacts~1';
CCRM='Business User~Signer 1;OppOwner~Signer 2';
LA='0';
CEM='Hello World,\\n\\nThis should be a double line break.';
//********* 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;
//*******************************************//
}
}
我收到的当前错误消息是"资格未定义" 。
资格认证是我的商机上的选择列表的当前值。如果我更改此值,则错误消息将反映该值。
提前致谢。
答案 0 :(得分:1)
修订后的代码现在触发了我想要的行为:
{!REQUIRESCRIPT("/apex/DocuSign_JavaScript")}
var oppStage = "Closed Won";
var OpptyStage = '{!Opportunity.StageName}';
if (OpptyStage!=oppStage)
{
alert("Unable to send envelope. Opportunity Stage does not equal Closed won.");
}
else {
//********* 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='';
//*************************************************//
CES="Hello World";
CRL='FirstName~{!URLENCODE(User.FirstName)};LastName~{!URLENCODE(User.LastName)};Email~{!URLENCODE(User.Email)};Role~OppOwner;RoutingOrder~2,LoadDefaultContacts~1';
CCRM='Business User~Signer 1;OppOwner~Signer 2';
LA='0';
CEM='Hello World,\\n\\nThis should be a double line break.';
//********* 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;
//*******************************************//
}