ResultSet Object in SuiteScript: Working with Search Results
The ResultSet object in SuiteScript allows developers to manage, iterate, and access search results up to 4000 records.
The ResultSet object encapsulates a collection of search results returned by the Search.run() method. This object is crucial for developers working with SuiteScript as it facilitates effective iteration and retrieval of search results. A key limitation to note is that a ResultSet can hold a maximum of 4000 results; for searches exceeding this number, you must use Search.runPaged() or Search.runPaged.promise() to access the complete result set.
Important Considerations
- Non-Caching: Result sets are not cached. If records relevant to your search are added, modified, or deleted during your interaction with the ResultSet, the results may change dynamically.
- Text Column Limits: Text columns in search results are constrained to a maximum of 4000 bytes. This limit is significant when dealing with character sets that may require more than one byte per character, thus potentially decreasing the effective character limit.
Supported Script Types
You can use the ResultSet in both client and server scripts, providing flexibility depending on your development needs.
Module
The ResultSet belongs to the N/search module, which is essential for executing searches in SuiteScript.
Methods and Properties
The ResultSet object supports various methods and properties that allow you to iterate through search results effectively. Major members include:
| Method/Property | Type | Description |
|---|---|---|
each(callback) | Method | Executes a callback function for each search result. |
getValue(options) | Method | Retrieves the value of a specified search result column. |
Code Sample
Below is an example demonstrating how to utilize the ResultSet object to load and run a saved search:
1// Load a saved search2var mySearch = search.load({3 id: 'customsearch_my_cs_search'4});5 6// Execute search and process each result7mySearch.run().each(function(result) {8 var entity = result.getValue({ name: 'entityid' });9 log.debug(entity);10 11 var email = result.getValue({ name: 'email' });12 log.debug(email);13 14 return true; // Return true to continue iteration15});Who This Affects
- Developers: Anyone building scripts that leverage search functionalities in NetSuite can benefit from understanding and using the ResultSet object effectively.
- Administrators: Those managing or configuring saved searches may find this information useful when guiding developers or troubleshooting issues.
Key Takeaways
- The ResultSet object allows handling up to 4000 search results.
- Searches executed dynamically are not cached, affecting real-time data interaction.
- Use
Search.runPaged()for result sets exceeding 4000 entries. - Ensure to consider text limits in search columns due to varying byte sizes.
Frequently Asked Questions (4)
When should I use Search.runPaged() instead of ResultSet?
Can I use the ResultSet object for both client and server-side scripts in SuiteScript?
Does the ResultSet object cache the search results?
Are there limitations on the text column data within a ResultSet object?
Was this article helpful?
More in Searches
- Creating Searches with SuiteScript in NetSuite
Create and manage searches in NetSuite with SuiteScript, utilizing filters, columns, and settings effectively.
- Filter Object Members for N/Search Module in NetSuite
Filter Object Members enhance search capabilities in NetSuite SuiteScript. Learn to create and configure filters effectively.
- 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.
- Error Handling in Searches with SuiteScript 2.0 Features
Gain insights into error handling in SuiteScript searches, including codes and common issues that arise when loading saved searches.
Advertising
Reach Searches Professionals
Put your product in front of NetSuite experts who work with Searches every day.
Sponsor This Category