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.

·2 min read·View Oracle Docs

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.Search object
  • 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:

ParameterTypeRequired / OptionalDescription
options.idstringRequiredInternal ID or script ID of the saved search. The script ID must start with customsearch.
options.typestringRequired if applicableSpecifies 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 CodeMessageThrown If
INVALID_SEARCHThat 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:

suitescript
// Load an existing saved search
var 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

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • The search.load method retrieves existing saved searches for reuse.
  • Understanding parameters like options.id and options.type is 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?
You need to provide the 'options.id' parameter, which is the internal ID or script ID of the saved search. The 'options.type' parameter is required if the saved search uses a standalone search type.
How does the search.load method handle errors in SuiteScript 2.x?
The search.load method throws error codes such as 'INVALID_SEARCH' when the saved search ID is invalid and 'SSS_MISSING_REQD_ARGUMENT' when a required parameter is missing.
Does the search.load method in SuiteScript 2.x require governance units?
Yes, using the search.load method requires 5 governance units.
Is the search.type parameter necessary for all saved searches when using search.load?
No, the 'options.type' parameter is only necessary if the saved search uses a standalone search type, which doesn't correspond to a specific record type.
Source: Syntax 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 General

View all General articles →