-
StackOverflow 文件
-
netsuite 教程
-
使用子列表
-
1.0 標準模式下的子列表
// Working with Sublists in Standard mode ...
// ... if the record is in context:
// Add item 456 with quantity 10 at the end of the item sublist
var nextIndex = nlapiGetLineItemCount("item") + 1;
nlapiSetLineItemValue("item", "item", nextIndex, 456);
nlapiSetLineItemValue("item", "quantity", nextIndex, 10);
// Inserting item 234 with quantity 3 at the beginning of a sublist
nlapiInsertLineItem("item", 1);
nlapiSetLineItemValue("item", "item", 1, 234);
nlapiSetLineItemValue("item", "quantity", 1, 3);
// Insert item 777 with quantity 2 before the end of the last item
var itemCount = nlapiGetLineItemCount("item");
nlapiInsertLineItem("item", itemCount);
nlapiSetLineItemValue("item", "item", itemCount, 777);
nlapiSetLineItemValue("item", "quantity", itemCount, 2);
// Remove the first line item
nlapiRemoveLineItem("item", 1);
// Remove the last line item
nlapiRemoveLineItem("item", nlapiGetLineItemCount("item"));
// ... or if we have a reference to the record (rec):
// Add item 456 with quantity 10 at the end of the item sublist
var nextIndex = rec.getLineItemCount("item") + 1;
rec.setLineItemValue("item", "item", nextIndex, 456);
rec.setLineItemValue("item", "quantity", nextIndex, 10);
// Insert item 777 with quantity 3 at the beginning of the sublist
rec.insertLineItem("item", 1);
rec.setLineItemValue("item", "item", 1, 777);
rec.setLineItemValue("item", "quantity", 1, 3);
// Remove the first line
rec.removeLineItem("item", 1);
// Remove the last line
rec.removeLineItem("item", rec.getLineItemCount("item"));