Netsuite客户端脚本,用于在某些项目添加到销售订单时创建弹出窗口



我正在尝试创建一个客户端脚本,以便在将某些项目添加到销售订单时显示消息。这可以在添加项目后立即执行,也可以在保存订单时执行。

我已经尝试了下面的脚本,但它会出现附加的错误。

function onSaveTriggerPopup (){
listText = [1883,1882]; // Change list of Internal Ids in this Array
//get the number of line items in the SO item sublist
var numLine = nlapiGetLineItemCount('item', 'item');
//Define the boolean variable to record if there is a match found between internal ID list and the line item internal ID
var found = false;
//loop over each line item to check item internal ID
for (var i = 1; i <= numLine; i++) {
//get line item internal ID
var ID = nlapiGetLineItemValue('item', 'item', i);
//check if current item internal ID is inside the internal ID list
//This will return '-1' if no match found, and return the index number for a match
var returnCode = listArray.indexOf(ID);
//check if a match found, if this is true, the script will set bool variable found to be true
if (returnCode != '-1') {
found = true;
nlapiLogExecution('DEBUG', 'found an line item with internalID: ' + ID, '-');
break;
}
}
//pop-up alert window if a match found
if (found == true) {
alert("Have you added a partner?");
}
}

收到错误消息

如有任何帮助,我们将不胜感激。

错误是由以下行引起的:

var returnCode = listArray.indexOf(ID);

listArray变量是未定义的。

最新更新