ResultSet Object Members for SuiteScript Development

ResultSet object members provide key methods and properties for handling query results in SuiteScript efficiently.

·2 min read·View Oracle Docs

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 NameReturn TypeDescription
ResultSet.columnsquery.Column[] (read-only)An array of references to the query result columns.
ResultSet.resultsquery.Result[] (read-only)An array of query.Result objects retrieved by the query.
ResultSet.typesstring[] (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:

suitescript
1// Add additional code
2...
3 var myCustomerQuery = query.create({
4 type: query.Type.CUSTOMER
5 });
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 code

Conclusion

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() and iterator() for handling query results.
  • Properties like columns, results, and types offer 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?
The ResultSet.asMappedResults() method returns the query result set as an array of JavaScript objects, where each result is transformed into a key-value pair format. This is useful for accessing and manipulating data conveniently in SuiteScript.
How can I handle query results larger than the 5000 record limit in ResultSet?
To manage datasets larger than the 5000 record limit in a ResultSet, you should use the Query.runPaged(options) or Query.runPaged.promise(options) methods. These methods effectively handle paging through results in your SuiteScript development.
What does the ResultSet.iterator() method provide to developers?
The ResultSet.iterator() method provides an Iterator object that allows developers to traverse through the query results in a controlled manner, enabling more efficient data handling during SuiteScript execution.
Are the properties within ResultSet, such as 'columns', mutable?
No, properties like 'columns', 'results', and 'types' within ResultSet are read-only. They provide important information about the query results, such as references to columns and result types, but cannot be altered directly.
Source: ResultSet Object Members 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 Platform

View all Platform articles →