ResultSet Object Members for SuiteScript Development
ResultSet object members provide key methods and properties for handling query results in SuiteScript efficiently.
The ResultSet object members are essential for developers working with SuiteScript to manipulate and access query results effectively. This object contains various methods and properties that enhance the capabilities of database querying within the NetSuite environment.
What Methods Are Available in the ResultSet?
The ResultSet object includes two primary methods:
ResultSet.asMappedResults()
Returns a query result set as an array of JavaScript objects, transforming each result into a key-value pair format. This method is useful for accessing data conveniently.
ResultSet.iterator()
Provides an Iterator object that allows developers to traverse through the results in a more controlled manner, ensuring efficient data handling.
What Properties Are Included in the ResultSet?
The ResultSet contains several properties that deliver important information about the query results:
| Property Name | Return Type | Description |
|---|---|---|
ResultSet.columns | query.Column[] (read-only) | An array of references to the query result columns. |
ResultSet.results | query.Result[] (read-only) | An array of query.Result objects retrieved by the query. |
ResultSet.types | string[] (read-only) | An array of the return types for the retrieved results. |
Understanding the ResultSet Object
The ResultSet object encapsulates the results returned from a query executed using the query module. You can create this object by executing a query with either the Query.run(options) or the Query.run.promise() methods.
A crucial note: The maximum number of results you can handle in a ResultSet object is limited to 5000. For larger datasets, utilize Query.runPaged(options) or Query.runPaged.promise(options) to retrieve all results effectively.
Syntax Example
Here's a simplified example demonstrating how to work with the ResultSet object in your SuiteScript:
1// Add additional code2...3 var myCustomerQuery = query.create({4 type: query.Type.CUSTOMER5 });6 myCustomerQuery.columns = [7 myCustomerQuery.createColumn({8 fieldId: 'entityid'9 }),10 myCustomerQuery.createColumn({11 fieldId: 'email'12 })13 ];14 var resultSet = myCustomerQuery.run();15 var results = resultSet.results;16 for (var i = results.length - 1; i >= 0; i--)17 log.debug(results[i].values);18...19// Add additional codeConclusion
The ResultSet object members are integral in managing query results within SuiteScript, allowing developers to efficiently access and iterate over the data retrieved from NetSuite records. Understanding these features will enhance your development capabilities when utilizing the query module effectively.
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- The ResultSet object provides crucial methods such as
asMappedResults()anditerator()for handling query results. - Properties like
columns,results, andtypesoffer versatile data access. - Utilize paging methods for managing large datasets beyond the 5000 results limit.
Frequently Asked Questions (4)
What is the purpose of the ResultSet.asMappedResults() method in SuiteScript?
How can I handle query results larger than the 5000 record limit in ResultSet?
What does the ResultSet.iterator() method provide to developers?
Are the properties within ResultSet, such as 'columns', mutable?
Was this article helpful?
More in Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category