N/search Module

Use the N/search module to create and run on-demand or saved searches and analyze and iterate through the search results. You can use this module to do the following:

You can also paginate search results and construct navigation that jumps between the next and previous pages. Due to the performance benefits, this is a suitable approach for working with a large result set.

                                   

In This Help Topic

N/search Module Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Object

search.Column

Object

Client and server scripts

Encapsulates a single search column in a search.Search object. Use the methods and properties available to the Column object to get or set Column properties.

search.Filter

Object

Client and server scripts

Encapsulates a search filter used in a search. Use the properties for the Filter object to get and set the filter properties.

search.Page

Object

Client and server scripts

Encapsulates a set of search results for a single search page.

search.PagedData

Object

Client and server scripts

Holds metadata about a paginated query.

search.PageRange

Object

Client and server scripts

Defines the page range to bound the result set for a paginated query.

search.Result

Object

Client and server scripts

Encapsulate a single search result row. Use the methods and properties for the Result object to get the column values for the result row.

search.ResultSet

Object

Client and server scripts

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

search.Search

Object

Client and server scripts

Encapsulates a NetSuite search. Use the methods available to the Search object to create a search, run a search, or save a search.

search.Setting

Object

Client and server scripts

Encapsulates a search setting. Search settings let you specify search parameters that are typically available only in the UI.

Method

search.create(options)

search.Search

Client and server scripts

Creates a new search and returns it as a search.Search object.

search.create.promise(options)

search.Search

Client and server scripts

Creates a new search asynchronously and returns it as a search.Search object.

search.createColumn(options)

search.Column

Client and server scripts

Creates a new search column as a search.Column object.

search.createFilter(options)

search.Filter

Client and server scripts

Creates a new search filter as a search.Filter object.

search.createSetting(options)

search.Setting

Client and server scripts

Creates a new search setting and returns it as a search.Setting object.

search.delete(options)

void

Client and server scripts

Deletes an existing saved search asynchronously and returns it as a search.Search object.

search.delete.promise(options)

void

Client and server scripts

Deletes an existing saved search and returns it as a search.Search object.

search.duplicates(options)

search.Result[]

Client and server scripts

Performs a search for duplicate records based on the duplicate detection configuration for the account. Returns an array of search.Result objects.

search.duplicates.promise(options)

search.Result[]

Client and server scripts

Performs a search for duplicate records asynchronously based on the duplicate detection configuration for the account. Returns an array of search.Result objects.

search.global(options)

search.Result[]

Client and server scripts

Performs a global search against a single keyword or multiple keywords.

search.global.promise(options)

search.Result[]

Client and server scripts

Performs a global search asynchronously against a single keyword or multiple keywords.

search.load(options)

search.Search

Client and server scripts

Loads an existing saved search and returns it as a search.Search object.

search.load.promise(options)

search.Search

Client and server scripts

Loads an existing saved search asynchronously and returns it as a search.Search object.

search.lookupFields(options)

Object | array

Client and server scripts

Performs a search for one or more body fields on a record. Returns select fields as an object with value and text properties. Returns multiselect fields as an object with value:text pairs.

search.lookupFields.promise(options)

Object | array

Client and server scripts

Performs a search asynchronously for one or more body fields on a record. Returns select fields as an object with value and text properties. Returns multiselect fields as an object with value:text pairs.

Enum

search.Operator

enum

Client and server scripts

Enumeration that holds the values for search operators to use with the search.Filter object.

search.Sort

enum

Client and server scripts

Holds the values for supported sorting directions used with search.createColumn(options).

search.Summary

enum

Client and server scripts

Holds the values for summary types used by the Column.summary object.

search.Type

enum

Client and server scripts

Holds the string values for search types supported in the N/search Module. This enum is used to pass the type argument to search.create(options).

Column Object Members

The following members are available for a search.Column object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Column.setWhenOrderedBy(options)

search.Column

Client and server scripts

Returns the search column for which the minimal or maximal value should be found when returning the search.Column value.

Property

Column.formula

string

Client and server scripts

Formula used for a search column as a string.

Column.function

string

Client and server scripts

Special function used in the search column as a string.

Column.join

string (read-only)

Client and server scripts

Join ID for a search column as a string.

Column.label

string

Client and server scripts

Label used for the search column. You can only get or set custom labels with this property.

Column.name

string (read-only)

Client and server scripts

Name of a search column as a string.

Column.summary

string (read-only)

Client and server scripts

Returns the summary type for a search column.

Filter Object Members

The following members are available for a search.Filter object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Filter.formula

string

Client and server scripts

Formula used by the search filter.

Filter.join

string (read-only)

Client and server scripts

Join ID for the search filter.

Filter.name

string (read-only)

Client and server scripts

Name or internal ID of the search field.

Filter.operator

string (read-only)

Client and server scripts

Operator used for the search filter.

Filter.summary

search.Summary

Client and server scripts

Summary type for the search filter.

Page Object Members

The following members are available for a search.Page object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Page.next()

void

Client and server scripts

Gets the next segment of data from a paginated search

Page.next.promise()

void

Client scripts

Asynchronously gets the next segment of data from a paginated search

Page.prev()

void

Client and server scripts

Gets the previous segment of data from a paginated search

Page.prev.promise()

void

Client scripts

Asynchronously gets the previous segment of data from a paginated search

Property

Page.data

search.Result[]

Client and server scripts

The results from a paginated search.

Page.isFirst

boolean (read-only)

Client and server scripts

Indicates whether a page is the first page of data for a result set

Page.isLast

boolean (read-only)

Client and server scripts

Indicates whether a page is the last page of data for a result set.

Page.pagedData

search.PagedData (read-only)

Client and server scripts

The PagedData Object used to fetch this Page Object.

Page.pageRange

search.PageRange (read-only)

Client and server scripts

The PageRange Object used to fetch this Page Object.

PagedData Object Members

The following members are available for a search.PagedData object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

PagedData.fetch(options)

search.Page

Client and server scripts

Retrieves the data within the specified page range.

PagedData.fetch.promise()

search.Page

Client scripts

Asynchronously retrieves the data within the specified page range.

Property

PagedData.count

number (read-only)

Client and server scripts

The total number of results when Search.runPaged(options) was executed.

PagedData.pageRanges

search.PageRange[] (read-only)

Client and server scripts

The collection of PageRange objects that divide the entire result set into smaller groups.

PagedData.pageSize

number (read-only)

Client and server scripts

The maximum number of entries per page

PagedData.searchDefinition

search.Search (read-only)

Client and server scripts

The search criteria used when Search.runPaged(options) was executed.

PageRange Object Members

The following members are available for a search.PageRange object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

PageRange.compoundLabel

string (read-only)

Client and server scripts

Human-readable label with beginning and ending range identifiers

PageRange.index

number (read-only)

Client and server scripts

The index of this page range.

Result Object Members

The following members are available for a search.Result object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Result.getText(column)

string

Client and server scripts

The text value for a search.Column if it is a stored select field.

Result.getText(options)

string

Client and server scripts

The UI display name, or text value, for a search result column. This method is supported only for non-stored select, image, and document fields.

Result.getValue(options)

string

Client and server scripts

Used on formula fields and non-formula (standard) fields to get the value of a specified search return column.

Result.getValue(column)

string

Client and server scripts

Used on formula and non-formula (standard) fields. Returns the string value of a specified search result column. For convenience, this method takes a single search.Column Object.

Property

Result.columns

search.Column[]

Client and server scripts

Array of search.Column objects that encapsulate the columns returned in the search result row.

Result.id

string (read-only)

Client and server scripts

The internal ID for the record returned in a search result row.

Result.recordType

string (read-only)

Client and server scripts

The type of record returned in a search result row.

ResultSet Object Members

The following members are available for a search.ResultSet object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

ResultSet.each(callback)

void

Client and server scripts

Use a developer-defined function to invoke on each row in the search results, up to 4000 results at a time.

ResultSet.each.promise(callback)

void

Client scripts

Asynchronously use a developer-defined function to invoke on each row in the search results, up to 4000 results at a time.

ResultSet.getRange(options)

search.Result[]

Client and server scripts

Retrieve a slice of the search result as an array of search.Result objects.

ResultSet.getRange.promise(options)

search.Result[]

Client scripts

Asynchronously retrieve a slice of the search result as an array of search.Result objects.

Property

ResultSet.columns

search.Column[]

Client and server scripts

An array of search.Column objects that represent the columns returned in the search results.

Search Object Members

The following members are available for a search.Search object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Search.run()

search.ResultSet

Client and server scripts

Runs an on demand search created with search.create(options) or a search loaded with search.load(options), returning the results as a search.ResultSet.

Search.runPaged(options)

search.PagedData

Client and server scripts

Runs the current search and returns a search.PagedData Object.

Search.runPaged.promise(options)

search.PagedData

Client and server scripts

Asynchronously runs the current search and returns a search.PagedData Object.

Search.save()

number

Client and server scripts

Saves a search created by search.create(options) or loaded with search.load(options). Returns the internal ID of the saved search.

Search.save.promise()

number

Client and server scripts

Asynchronously saves a search created by search.create(options) or loaded with search.load(options). Returns the internal ID of the saved search.

Property

Search.columns

search.Column[] | string[]

Client and server scripts

Columns to return for this search as an array of search.Column objects or a string array of column names.

Search.filterExpression

Object[]

Client and server scripts

Search filter expression for the search as an array of expression objects.

Search.filters

search.Filter[]

Client and server scripts

Filters for the search as an array of search.Filter objects.

Search.id

string

Client and server scripts

Script ID for a saved search, starting with customsearch.

Search.isPublic

boolean

Client and server scripts

Value is true if the search is public, or false if it is not.

Search.packageId

string

Client and server scripts

The application ID for the search.

Search.searchId

number

Client and server scripts

Internal ID of a search.

Search.searchType

string

Client and server scripts

Search type on which a search is based.

Search.settings

search.Setting[] | string[]

Client and server scripts

Search settings for this search as an array of search.Setting objects or a string array of column names.

Search.title

string

Client and server scripts

Title for a saved search. Use this property to set the title for a search before you save it for the first time.

Setting Object Members

The following members are available for a search.Setting object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Setting.name

string (read-only)

Client and server scripts

The name of the search parameter.

Setting.value

string (read-only)

Client and server scripts

The value of the search parameter.

Related Support Article

SuiteScript 2.0 > N/search Module > Add a Filter on a Loaded Search Record

Related Topics

SuiteScript 2.x Modules
SuiteScript 2.x

General Notices