util.each(iterable, callback)
The content in this help topic pertains to SuiteScript 2.0.
Method Description |
Iterates over each member in an Object or Array. This method calls the |
Returns |
The original collection as an Object | Array |
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2016.1 |
Parameters
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
iterable |
Object | Array |
required |
The data collection to iterate on. |
2016.1 |
callback |
Function |
required |
Takes the custom logic that you want to execute on each member of your collection of data. |
2016.1 |
Syntax
The following code snippet shows the syntax for this member. It is not a functional example. For a full script sample, see N/util Module Script Sample.
//Add additional code
...
// Iterate through the object and set the key-value pairs on the record
util.each(itemList, function(quantity, itemId){
rec.selectNewLine('item');
rec.setCurrentSublistValue('item','item',itemId);
rec.setCurrentSublistValue('item','quantity',quantity);
rec.commitLine('item');
});
...
//Add additional code