Modules

filter

 

Objects/Functions

module (N/util)

SuiteScript 2.0

Main Examples

N/util Module
Member Type: Name
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=N/util Module

// Code Example 1
/**
* @NApiVersion 2.x
*/

require(['N/record'], function(record){
// Create a sales order
var rec = record.create({
type: 'salesorder',
isDynamic: true
});
rec.setValue({
fieldId: 'entity',
value: 107
});

// Set up an object containing an item's internal ID and the corresponding quantity
var itemList = {
39: 5,
38: 1
}

// Iterate through the object and set the key-value pairs on the record
util.each(itemList, function(quantity, itemId){ // (5, 39) and (1, 38)
rec.selectNewLine('item');
rec.setCurrentSublistValue('item','item',itemId);
rec.setCurrentSublistValue('item','quantity',quantity);
rec.commitLine('item');
});

var id = rec.save();
});

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4569538303.html