Search Load Method for SuiteScript 2.x Development
The search.load method in SuiteScript 2.x allows developers to load existing saved searches efficiently, ensuring seamless integration in scripting tasks.
The search.load method in SuiteScript 2.x is essential for loading existing saved searches into your scripts. This feature allows you to leverage previously created searches—whether they were built using the user interface or programmatically with the search.create(options) and Search.save() methods. By using this method, developers can streamline their scripts and enhance functionality.
Method Overview
- Method:
search.load(options) - Returns: A
search.Searchobject - Supported Script Types: Client and server scripts
- Governance: 5 units
- Module: N/search Module
Parameters
The options parameter is a JavaScript object that contains the following:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.id | string | Required | Internal ID or script ID of the saved search. The script ID must start with customsearch. |
options.type | string | Required if applicable | Specifies the search type of the saved search. This is necessary if the saved search uses a standalone search type, which does not correspond to a specific record type. Typical usage involves using predefined enums available in the search.Type enumeration. |
Here are some examples of standalone search types:
- DeletedRecord
- EndToEndTime
- ExpenseAmortPlanAndSchedule
- RevRecPlanAndSchedule
- InventoryBalance
Note: The options.type parameter is required if the saved search uses a standalone search type; otherwise, it is optional.
Error Handling
When using the search.load method, you might encounter the following error codes:
| Error Code | Message | Thrown If |
|---|---|---|
INVALID_SEARCH | That search or mass update does not exist. | The saved search ID in options.id is invalid. |
SSS_MISSING_REQD_ARGUMENT | {1}: Missing a required argument: {2} | A required parameter is missing in the request. |
Example Usage
Below is a basic syntax example demonstrating how to utilize the search.load method:
// Load an existing saved searchvar mySearch = search.load({ id: 'customsearch_my_so_search'});This method ensures efficiency by enabling scripts to access predefined searches without needing to recreate them, thereby streamlining the search process in SuiteScript.
Related Topics
- N/search Module
- SuiteScript 2.x Modules
- SuiteScript 2.x
Key Takeaways
- The
search.loadmethod retrieves existing saved searches for reuse. - Understanding parameters like
options.idandoptions.typeis critical. - Error codes provide valuable feedback during script execution.
Frequently Asked Questions (4)
What parameters are required to use the search.load method in SuiteScript 2.x?
How does the search.load method handle errors in SuiteScript 2.x?
Does the search.load method in SuiteScript 2.x require governance units?
Is the search.type parameter necessary for all saved searches when using search.load?
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.
- PagedData Object Members in NetSuite SuiteScript 2.0
PagedData provides efficient pagination for search results in SuiteScript, enabling effective handling of large data sets.
- Search Object Errors in SuiteScript for NetSuite
Understand common search object errors in SuiteScript for NetSuite and how to resolve them effectively.
- Search Filter Object Usage in SuiteScript
The Search Filter object enables refined query capabilities in SuiteScript, encapsulating search criteria.
Advertising
Reach Searches Professionals
Put your product in front of NetSuite experts who work with Searches every day.
Sponsor This Category