N/search Module Syntax for SuiteScript Development
Learn the syntax for the N/search module in SuiteScript, enabling effective search result manipulation in NetSuite.
TL;DR
The N/search module in SuiteScript provides syntax to encapsulate a single search result row, allowing developers to efficiently retrieve and manipulate data from saved searches and dynamic queries. This functionality is crucial for developing robust scripts that interact with large datasets in NetSuite.
What is the N/search Module?
The N/search module provides tools for querying NetSuite records. It includes methods for loading saved searches, running searches, and obtaining search results.
Object Description
The primary object encapsulates a single search result row. You can use the methods and properties for search results to get the corresponding column values for each row. For retrieving multiple results, the ResultSet object should be used, allowing you to iterate through or slice the set of results.
Important Notes
- Text columns in search results have a limit of 4000 bytes, which in English translates to 4000 characters. This limit may vary for other character sets, potentially reducing the character capacity.
- Custom multiselect fields of type "long text" are truncated at 4000 characters. In multi-language accounts, the truncation can occur at 1,300 characters, while in single-language accounts, it is commonly at 3,900 characters. To retrieve full results without truncation, consider using the
record.load(options)method instead.
Supported Script Types
The N/search module can be utilized in both client and server scripts. For a detailed exploration of applicable script types, refer to the SuiteScript 2.x documentation.
Syntax Example
Here is a syntax example showcasing how to load and run a saved search:
1// Add additional code2...3var mySearch = search.load({4 id: 'customsearch_my_so_search'5});6 7var searchResult = mySearch.run().getRange({8 start: 0,9 end: 10010});11for (var i = 0; i < searchResult.length; i++) {12 var entity = searchResult[i].getValue({13 name: 'entity'14 });15 var subsidiary = searchResult[i].getValue({16 name: 'subsidiary'17 });18 // Add additional code19}Conclusion
Understanding the syntax and limitations of the N/search module is essential for effective SuiteScript development in NetSuite. It enables developers to craft tailored scripts that process meaningful search results, vital for data-driven applications.
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- The N/search module is vital for obtaining and manipulating search results in SuiteScript.
- Text columns have limitations that can affect data retrieval accuracy, especially with multiselect fields.
- The provided syntax enables you to effectively load and process saved searches.
- Custom scripts can enhance data handling capabilities significantly in the NetSuite environment.
Frequently Asked Questions (4)
What limitations exist for text columns when using the N/search module?
Can the N/search module be used in client scripts?
How can I retrieve full results for custom multiselect fields without truncation?
Does the N/search module provide a way to iterate over multiple search results?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Custom Tool Script Enhancements in NetSuite
Custom tool scripts in NetSuite gain execution log support and a new management page in February 16, 2026.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
