search.ResultSet

Note:

The content in this help topic pertains to SuiteScript 2.0.

Object Description

Encapsulates a set of search results returned by Search.run().

Use the methods and properties for the ResultSet object to iterate through each result returned by the search or access an arbitrary slice of results. The maximum number of results in a ResultSet object is 4000. If a search matches more than 4000 results, you must use Search.runPaged(options) or Search.runPaged.promise(options) to retrieve the full set of results.

For a complete list of this object’s methods and properties, see ResultSet Object Members.

Important:

Search result sets are not cached. If records applicable to your search are created, modified, or deleted at the same time you are traversing your result set, your result set may change.

Supported Script Types

Client and server scripts

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

Module

N/search Module

Since

2015.2

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 
...
// Load a saved search. Alternatively, you can create a search using search.create(options)
// and other methods in the N/search module.
var mySearch = search.load({
    id: 'customsearch_my_cs_search'
});

// Run the search, and use ResultSet.each(callback) to define a callback function to
// execute on each search result.
//
// In this example, the saved search that was loaded above searches for Customer records.
// The Result.getValue(options) method obtains the search result value of one of the search
// columns that was specified in the search definition. Both 'entityid' and 'email' are valid
// search column names for a Customer record.
mySearch.run().each(function(result) {
    var entity = result.getValue({
        name: 'entityid'
    });
    log.debug(entity);

    var email = result.getValue({
        name: 'email'
    });
    log.debug(email);

    return true;
});
...
// Add additional code 

        

Related Topics

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

General Notices