ResultSet.each(callback)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Use a developer-defined function to invoke on each row in the search results, up to 4000 results at a time. The callback function must use the following signature:

boolean callback(result.Result result);

The callback function takes a search.Result object as an input parameter and returns a boolean which can be used to stop the iteration with a value of false, or continue the iteration with a value of true.

Important:

The work done in the context of the callback function counts toward the governance of the script that called it. For example, if the callback function is running in the context of a scheduled script, which has a 10,000 unit governance limit, make sure the amount of processing within the callback function does not place the entire script at risk of exceeding scheduled script governance limits.

Returns

void

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/search Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

callback

function

Required

Named JavaScript function or anonymous inline function that contains the logic to process a search.Result object.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/search Module Script Samples.

           //Add additional code  
...
mySearch.run().each(function(result) {
    var entity = result.getValue({
        name: 'entity'
    });
    var subsidiary = result.getValue({
        name: 'subsidiary'
    });
    return true;
});
...
//Add additional code 

        

Related Topics

search.ResultSet
N/search Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices