runSavedSearch()
The runSavedSearch() function (server-side) runs a previously created NetSuite saved search and returns the results. All search parameters must be defined within the saved search. Examples of search parameters include the record type and the selected fields.
Syntax
Use these syntax formats for the runSavedSearch() function:
-
To pass an object as a parameter:
runSavedSearch({ id: string, async: true | false }).done(callback); -
To pass the saved search ID as a string parameter:
runSavedSearch('savedSearchId').done(callback);
Return Value
The runSavedSearch() function returns a promise that resolves to an array of objects representing the saved search results.
Parameters
The id property is required.
The runSavedSearch() function accepts an object as a parameter. The object includes the following properties:
-
id(string) - Specifies the unique identifier of the NetSuite saved search to run. -
async(trueorfalse) - Determines whether to run the search asynchronously or synchronously. This property istrueby default.
Examples
The following examples show how to use the runSavedSearch() function.
Retrieving Results From a Saved Search
This example retrieves data synchronously from a specific saved search by passing an options object with async: false. The callback function logs the results to the console. Running the search synchronously ensures that results are returned before moving to the next line of code.
runSavedSearch({
id: 'customsearch_desks2',
async: false
}).done(function(data) {
console.log('Done', data);
});