当用户在我们的 SCA Mont Blanc 网站上注册时,我们需要在创建用户之前检查他们的电子邮件是否唯一。因此,在注册新用户之前,我们编辑了该Accounts@1.X.X/SuiteScript/Account.Model.js
文件以检查Customer
具有特定电子邮件地址的任何用户的表格。
问题是:该脚本在角色下执行,Customer Center
并且没有查看/查询Customer
表的权限。所以我们的检查使脚本崩溃。
我们如何Customer
在用户注册时访问该表(特别是文件Accounts@1.X.X/SuiteScript/Account.Model.js
)?您可以提供任何解决方案/建议吗,因为我很困惑:(
我尝试过的事情:
- 更改服务文件的角色/权限
services/Account.Register.Service.ss
以在我创建的名为Webstore User
. 不幸的是,这导致登录页面显示错误;You do not have permission to view this page
. 也许我没有更改正确的文件或正确设置新角色? - 创建了一个新角色,该角色具有所有权限
Customer Centre
plusview
权限Customers
。但与上述相同的错误。
AccountOverrides@1.0.0/SuiteScript/Account.Model.js
...
return SCModel.extend({
name: 'Account'
, register: function (user_data)
{
// Check if there is already a user/customer with this email address
// The below function will crash the script because
// the script cannot access the 'customer' table
var emailDulicates = nlapiSearchRecord('customer', null,
new nlobjSearchFilter('email', null, 'is', ''+user_data.email));
if (emailDulicates && emailDulicates.length > 0) {
Application.sendError({"Email already taken."});
return false;
}
... continue on to register user
}
});