util.each(iterable, callback)

Method Description

Iterates over each member in an Object or Array.

This method calls the callback function on each member of the iterable.

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

N/util 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
Important:

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 

        

Related Topics

General Notices