[英]Access Customer Table from within SCA SuiteScript
當用戶在我們的SCA Mont Blanc網站上注冊時,我們需要在創建用戶之前檢查其電子郵件是否唯一。 因此,在注冊新用戶之前,我們已經編輯了Accounts@1.XX/SuiteScript/Account.Model.js
文件,以檢查Customer
表中是否有具有特定電子郵件地址的所有用戶。
問題是:該腳本在“ Customer Center
”角色下執行,並且沒有查看/查詢“ Customer
表的權限。 因此,我們的檢查使腳本崩潰。
用戶注冊后(特別是文件Accounts@1.XX/SuiteScript/Account.Model.js
)如何訪問Customer
表? 你有什么解決方案/建議可以提供,因為我很受困擾:(
我嘗試過的事情:
services/Account.Register.Service.ss
的角色/權限更改為在我創建的新角色Webstore User
下執行。 不幸的是,這導致登錄頁面顯示錯誤。 You do not have permission to view this page
。 也許我沒有更改正確的文件或正確設置新角色? Customer Centre
加view
許可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
}
});
我要做的是創建一個伴隨的.ss文件並為其授予權限。 然后,使用nlapiRequestURL對其進行調用,並取回數據。 這比Suitet更為方便,因為您可以將所有文件放在一起並擁有一個更簡單的URL來處理
您可以使用nlapiRequestURL將此服務器端稱為。 從SuiteScript / Account / Model.js或從services / Account.Register.Service.ss
您也可以稱其為客戶端,以便在注冊之前驗證電子郵件。 您將禁用“注冊”按鈕,直到獲得干凈的電子郵件評估。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.