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.
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:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.id | string | required | The internal ID or script ID of a saved search. IDs start with customsearch. |
options.type | string | required if using a standalone search type, optional otherwise | The type of saved search to load. Specify from the search.Type enum if it’s a standalone type. |
Some standalone search types include:
DeletedRecordExpenseAmortPlanAndScheduleGlLinesAuditLogInventoryStatusLocation
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 Code | Message | Thrown If |
|---|---|---|
INVALID_SEARCH | That 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:
// Load a saved search using its IDvar mySearch = search.load({ id: 'customsearch_my_so_search'});Related Topics
- N/search Module
- SuiteScript 2.x Modules
Key Takeaways:
- The
search.loadmethod 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?
How does the search.load method handle searches of standalone types?
What is the governance cost of using the search.load method in SuiteScript?
What kind of scripting environments support the search.load method?
Was this article helpful?
More in Searches
- Search for Sublist Line Fields With Dynamic Tables in NetSuite
Learn how to optimize search queries for sublist line fields in NetSuite using dynamic tables and SuiteQL.
- Filter Object Members in NetSuite SuiteScript
Gain insights into the Filter Object Members of the N/search module in NetSuite SuiteScript. Learn how to create and configure filters effectively.
- Search Column Syntax for SuiteScript 2.x in NetSuite
Search column syntax in SuiteScript 2.x allows encapsulation of fields in NetSuite searches, enhancing data retrieval capabilities.
- PagedData Object Members in NetSuite SuiteScript 2.0
PagedData provides efficient pagination for search results in SuiteScript, enabling effective handling of large data sets.
Advertising
Reach Searches Professionals
Put your product in front of NetSuite experts who work with Searches every day.
Sponsor This Category