Tutorial by Examples

// How many Items does a Sales Order have... // ... if we're in the context of a Sales Order record var itemCount = nlapiGetLineItemCount("item"); // ... or if we've loaded the Sales Order var order = nlapiLoadRecord("salesorder", 123); var itemCount = order.getLineItemC...
// 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); nlapiSetL...
// Adding a line item to the end of a sublist in Dynamic Mode... // ... if the record is in context: nlapiSelectNewLineItem("item"); nlapiSetCurrentLineItemValue("item", "item", 456); nlapiSetCurrentLineItemValue("item", "quantity", 10); nlapi...
// Which line has item 456 on it... // ... if we're in the context of a record var index = nlapiFindLineItemValue("item", "item", 456); if (index > -1) { // we found it... } else { // item 456 is not in the list } // ... or if we have a reference to the rec...
// How many lines in a sublist in SuiteScript 2.0... require(["N/record"], function (r) { var rec = r.load({ "type": r.Type.SALES_ORDER, "id": 123 }); // How many lines are on the Items sublist? var itemCount = rec.getLineCount...
// Working with a sublist in Standard Mode in SuiteScript 2.0... require(["N/record"], function (r) { var rec = r.create({ "type": r.Type.SALES_ORDER, "isDynamic": false }); // Set relevant body fields ... // Add line item 45...
// Working with Sublists in Dynamic Mode in SuiteScript 2.0... require(["N/record"], function (r) { var rec = r.create({ "type": r.Type.SALES_ORDER, "isDynamic": true }); // Set relevant body fields ... // Add line item 456 w...
// Finding a specific line item in SuiteScript 2.0... require(["N/record"], function (r) { var rec = r.load({ "type": r.Type.SALES_ORDER, "id": 123 }); // Find the line that contains item 777 var index = rec.findSublistLineWith...

Page 1 of 1