[英]Suitescript: Popup when item is added on sales order
當某些項目添加到 Netsuite 中的銷售訂單時,我希望出現一個彈出窗口。 彈出窗口應出現在創建和編輯時。 到目前為止,在我的代碼中,我希望在將項目編號 5071、1337 或 12345 添加到銷售訂單時出現彈出窗口。 但是當我部署腳本時沒有任何反應。 我已經為銷售訂單記錄中的所有角色部署了它。
有誰知道這里有什么問題? 以及如何添加以便腳本在每次顯示消息時記錄?
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/ui/dialog','N/record','N/currentRecord'],
function (dialog, record, currentRecord) {
function validateLine(context) {
var soRecord = context.currentRecord;
var list = context.sublistId === 'items';
var itemsArray = [507000, 124, 125];
var currentItem;
if (list) {
currentItem = soRecord.getCurrentSublistValue({
sublistId: 'items',
fieldId: 'item'
});
if (itemsArray.indexOf(currentItem) !== -1) {
dialog.alert({
title: 'Question?',
message: 'Please confirm this and that.'
}).then(success).catch(failure);
}
}
}
function success() {
return success;
}
function failure() {
return false;
}
return {
validateLine : validateLine
};
});
最多支持 10 個客戶端腳本。 如果您的腳本位於腳本記錄頁面的客戶端腳本子選項卡的第 11 個或更下方,它將不會運行。 (這可能取決於上面的腳本是否全部部署——我不知道如何計算 10 個的每一個細微差別)。 您可以更改腳本的順序以確保運行更重要的腳本,方法是編輯腳本記錄頁面,選擇要重新排序的腳本的行,然后拖動手柄(左側的 6 個點)。
要解決“10 個腳本限制”,您可以重構客戶端腳本以在單個腳本中包含更多功能。 如果您安裝了許多帶有鎖定客戶端腳本的捆綁包/SuiteApp,這仍然可能是一個問題,但您可以選擇優先考慮哪些。
您遇到的另一個問題是:
if (list) {
currentItem = soRecord.getCurrentSublistValue({
sublistId: 'items', //ON THIS LINE
fieldId: 'item'
});
if (itemsArray.indexOf(currentItem) !== -1) {
dialog.alert({
title: 'Question?',
message: 'Please confirm this and that.'
}).then(success).catch(failure);
}
}
您的alert
功能會根據存在的currentItem
有條件地運行。 但是, currentItem
取決於從items
子列表中提取的值,該值不存在。 正確的子列表 ID 是item
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.