【问题标题】:Salesforce custom button returning 'Unexpected Token ILLEGAL?Salesforce 自定义按钮返回“意外令牌非法?
【发布时间】:2015-08-19 12:51:55
【问题描述】:
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}

/*Getting the Running User Details*/
var result = 
sforce.connection.query(
    "SELECT Advisor__c " + 
    "FROM User " +
    "WHERE Id = '{!$User.Id}'"
);

/*Grab the Records returned by executing the above SOQL Query*/
var userDetails = result.getArray("records")[0];

/*Initializing the Contact record for Update*/
var contactToUpdate = new sforce.SObject("Contact");

contactToUpdate.Id = "{!Contact.Id}";

/*If the Running User is an "Advisor" then set the
Contact With and associated fields*/
if(userDetails.Advisor__c === true){
contactToUpdate.Contact_With__c = "{!$User.Id}";
contactToUpdate.Last_Advisor_Touch__c = new Da​te();
}
/*If the Running User isn't an "Advisor" then set the
Contact With 2 and associated fields*/
else{
contactToUpdate.Contact_With_2__c = "{!$User.Id}";
contactToUpdate.Last_Non_Advisor_Touch__c = new Date();
}

var result = sforce.connection.update([contactToUpdate]);

if(result[0].success === true){
location.reload();
}
else{
alert(result[0].errors.message);
}

我在我们的用户配置文件中添加了一个名为“顾问”的自定义复选框字段。该代码假设根据用户是否选中此框来区分要更新的字段。如果是则更新该字段,如果不是则更新该字段。相反,尽管它返回了“意外令牌非法”。不知道为什么。

【问题讨论】:

    标签: javascript unicode salesforce


    【解决方案1】:

    似乎您在下一行中有一个特殊的隐藏字符 contactToUpdate.Last_Advisor_Touch__c = new Da​ te();

    in word 日期 如果你只是重写它应该可以工作。 具体来说,你在 Da 和 te 之间有臭名昭著的 ZERO WIDTH SPACE 可能来自 this。要消除此类事情,您可以使用this toolthis one

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-11
      • 2012-11-07
      • 2015-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多