{!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"该代码用于根据用户是否选中此框来区分要更新的字段。如果是,请更新此字段,如果不更新该字段。相反,虽然它返回了一个'意外的令牌ILLEGAL。不知道为什么。
答案 0 :(得分:1)
好像你在下一行中有一个特殊的隐藏字符
install
字日期 如果你只是重写它应该工作。 具体来说,你和Da之间的臭名昭着的ZERO WIDTH SPACE可能来自this。要消除此类问题,您可以使用this tool或this one