Salesforce 自定义按钮返回“意外令牌非法?”
Salesforce custom button returning 'Unexpected Token ILLEGAL?
{!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 Date();
}
/*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);
}
我在名为 "Advisor" 的用户配置文件中添加了一个自定义复选框字段,该代码假设根据用户是否选中此框来区分要更新的字段。如果是更新这个字段,如果不是更新那个字段。相反,尽管它返回了一个“意外的令牌非法”。不知道为什么。
下一行似乎有一个特殊的隐藏字符
contactToUpdate.Last_Advisor_Touch__c = new Da te();
在单词日期
如果您只是重写它,它应该可以工作。
具体来说,你有臭名昭著的 ZERO WIDTH SPACE between Da and te probably comes from this. To eliminate such things you can use this tool or this one
{!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 Date();
}
/*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);
}
我在名为 "Advisor" 的用户配置文件中添加了一个自定义复选框字段,该代码假设根据用户是否选中此框来区分要更新的字段。如果是更新这个字段,如果不是更新那个字段。相反,尽管它返回了一个“意外的令牌非法”。不知道为什么。
下一行似乎有一个特殊的隐藏字符
contactToUpdate.Last_Advisor_Touch__c = new Da te();
在单词日期 如果您只是重写它,它应该可以工作。 具体来说,你有臭名昭著的 ZERO WIDTH SPACE between Da and te probably comes from this. To eliminate such things you can use this tool or this one