[英]NetSuite Loop thru inventorydetail Subrecord Suitescript 1.0
I'm trying to pull all the listed bin numbers inside the inventorydetail subrecord thru SS1.0.我正在尝试通过 SS1.0 提取inventorydetail 子记录中所有列出的箱号。 I'm using UE script but I am having trouble looping thru each inventory detail on multiple items:我正在使用 UE 脚本,但在遍历多个项目的每个库存详细信息时遇到问题:
Scenario: Item 1 = Inventory Details (Bin1 and Bin2) Item 2 = Inventory Details (Bin3 and Bin4)场景:项目 1 = 库存明细(Bin1 和 Bin2) 项目 2 = 库存明细(Bin3 和 Bin4)
I can pull the bins on item 1 but getting error when the script enters item 2. Please help on my code below:我可以拉项目 1 上的垃圾箱,但是当脚本进入项目 2 时出现错误。请帮助我的代码如下:
var recordid = nlapiGetNewRecord().getId();
var record = nlapiLoadRecord('itemfulfillment', recordid);
var linenum = record.getLineItemCount('item');
for (var i = 1; i <= linenum; i++) {
var subrec = record.viewLineItemSubrecord('item', 'inventorydetail', i);
var invnum = subrec.getLineItemCount('inventoryassignment');
for (var x = 1; x <= invnum; x++){
var invitem = subrec.getLineItemText('inventoryassignment', 'binnumber', x);
nlapiLogExecution('DEBUG', 'invitem ' + invitem);
}
}
Thanks in advance提前致谢
There are a few reasons that your line may not have an inventory detail record so you need to check if it is empty before accessing it.您的行可能没有库存详细信息记录有几个原因,因此您需要在访问之前检查它是否为空。 So something like:所以像:
var recordid = nlapiGetNewRecord().getId();
var record = nlapiLoadRecord('itemfulfillment', recordid);
var linenum = record.getLineItemCount('item');
for (var i = 1; i <= linenum; i++) {
var subrec = record.viewLineItemSubrecord('item', 'inventorydetail', i);
if(!subrec) {
nlapiLogExecution('DEBUG', 'no inventory detail at '+ i);
continue;
}
var invnum = subrec.getLineItemCount('inventoryassignment');
if(invnum <= 0) {
nlapiLogExecution('DEBUG', 'no inventory assignment lines at '+ i);
continue;
}
for (var x = 1; x <= invnum; x++){
var invitem = subrec.getLineItemText('inventoryassignment', 'binnumber', x);
nlapiLogExecution('DEBUG', 'invitem ' + invitem);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.