search.load Method for Saved Searches in SuiteScript

The search.load method allows developers to load existing saved searches in SuiteScript, enhancing data retrieval and management.

·2 min read·1 views·View Oracle Docs

The search.load method is a powerful SuiteScript functionality that loads an existing saved search, returning it as a search.Search object. This capability is essential for developers looking to either create or manipulate saved searches efficiently in NetSuite. The saved search could be created through the user interface or programmatically using the search.create(options) and Search.save() methods.

Method Description

When invoked, search.load(options) requires specific parameters to retrieve the saved search effectively. Additionally, it also features a promise-based version: search.load.promise(options), which supports modern JavaScript practices. For more insights about promises, refer to the Promise Object documentation.

Returns

  • Returns an instance of search.Search.

Supported Script Types

This method is compatible with both client and server scripts. For specifics, see the documentation on SuiteScript 2.x script types.

Governance

Utilizing the search.load method consumes 5 governance units.

Parameters

The options parameter is an object that provides the necessary details for the operation. Here’s a breakdown:

ParameterTypeRequired / OptionalDescription
options.idstringrequiredThe internal ID or script ID of a saved search. IDs start with customsearch.
options.typestringrequired if using a standalone search type, optional otherwiseThe type of saved search to load. Specify from the search.Type enum if it’s a standalone type.

Some standalone search types include:

  • DeletedRecord
  • ExpenseAmortPlanAndSchedule
  • GlLinesAuditLog
  • InventoryStatusLocation

It is important to note that the type parameter should be explicitly provided only when the saved search uses a standalone search type, which lacks a corresponding record type.

Error Codes

When using the search.load method, be aware of potential error codes:

Error CodeMessageThrown If
INVALID_SEARCHThat search or mass update does not exist.The saved search ID specified in options.id doesn’t exist.
SSS_MISSING_REQD_ARGUMENT{1}: Missing a required argument: {2}A required parameter is missing in the options.

Syntax Example

The following code snippet illustrates the syntax for using the search.load method. Note that this is not a functional example:

suitescript
// Load a saved search using its ID
var mySearch = search.load({
id: 'customsearch_my_so_search'
});

Related Topics

Key Takeaways:

  • The search.load method is vital for accessing saved searches in SuiteScript.
  • Understanding required parameters ensures successful search loading.
  • Utilizing promise versions can improve code efficiency and readability.

Frequently Asked Questions (4)

What parameters are required for using the search.load method?
The search.load method requires an 'options' object with at least the 'options.id' parameter, which is the internal ID or script ID of a saved search. If using a standalone search type, the 'options.type' parameter is also required.
How does the search.load method handle searches of standalone types?
For standalone search types, the 'options.type' parameter is required. This should be specified using values from the search.Type enum, as these types don't have a corresponding record type.
What is the governance cost of using the search.load method in SuiteScript?
The search.load method consumes 5 governance units each time it is called.
What kind of scripting environments support the search.load method?
The search.load method can be used in both client and server scripts, supporting a wide range of SuiteScript 2.x script types.
Source: Parameters Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Searches

View all Searches articles →