Salesforce JavaScript未终止的字符串常量错误

时间:2016-01-12 13:51:53

标签: javascript string salesforce constants

我使用JavaScript在Salesforce中创建了一个按钮,用于将查询(自定义对象)转换为注册(联系人)。该按钮适用于我自己以及我在相同配置文件和权限上登录的任何测试用户,但是我的一个用户在使用按钮时报告错误。

错误如下:

'未终止的字符串常量'

我在按钮中使用的代码如下:

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

alert('Migration in progress, this page will refresh once it is complete. Please click ok, Please DO NOT press this button again');

if ('{!Enquiry__c.Surname__c}' != ''){
if ('{!Enquiry__c.Client_if_already_on_the_system__c}' == ''){ 

var Reg = new sforce.SObject('Contact'); 

Reg.FirstName = '{!Enquiry__c.First_Name__c}'; 
Reg.LastName = '{!Enquiry__c.Surname__c}'; 
Reg.Gender__c = '{!Enquiry__c.Gender__c}'; 
Reg.MailingStreet = '{!Enquiry__c.Address__c}'; 
Reg.MailingPostalCode = '{!Enquiry__c.Post_Code__c}'; 
Reg.MailingCity = '{!Enquiry__c.City_Town__c}'; 
Reg.MailingState = '{!Enquiry__c.County__c}'; 
Reg.HomePhone = '{!Enquiry__c.Home_Number__c}'; 
Reg.MobilePhone = '{!Enquiry__c.Mobile_Number__c}'; 
Reg.Email = '{!Enquiry__c.E_mail__c}'; 
Reg.Lastest_Enquiry__c = '{!Enquiry__c.Id}'; 

result = sforce.connection.create([Reg]); 

if (result[0].success == 'true'){ 
alert('A new Registration with the name - ' + Reg.FirstName + ' ' + Reg.LastName + ' was successfully created, Please DO NOT press this button again as duplication\'s will be created, Your client will be automatically connected to this enquiry'); 
javascript: document.location.reload(true); 
} 
}else{ 
alert('Cannot Migrate to Registration as there is already a Client connected to this Enquiry'); 
}
}else{
alert('Cannot Migrate to Registration as Surname is blank!'); 
}

用户告诉我他们正在使用 IE 作为浏览器,我已经在Chrome,Edge和最新的IE上测试了该按钮。任何人都有什么错误的想法?

1 个答案:

答案 0 :(得分:0)

Reg.FirstName和LastName的类型是什么?你在这两个领域使用textarea类型吗? 因为如果用户使用回车符输入任何名称\ r或\ n警告将失败并出现相同的错误,并且它将基于输入随机。