PagedData Object Members in SuiteScript 2.0
PagedData object in SuiteScript 2.0 offers methods and properties for handling paged query results efficiently.
The PagedData object in SuiteScript 2.0 is essential for developers managing paged query results, providing a comprehensive set of methods and properties to streamline data retrieval.
What is the PagedData Object?
The PagedData object encapsulates a set of paged query results, allowing developers to work with extensive datasets effectively. This object can be created using the Query.runPaged(options) or Query.runPaged.promise(options) methods. Each call can return up to 1000 results per page, streamlining the handling of large data results in NetSuite.
What Are PagedData Object Members?
The PagedData object includes various methods and properties designed for efficient data manipulation. Below is a summary of these members:
Methods
| Member Name | Return Type | Supported Script Types | Description |
|---|---|---|---|
PagedData.iterator() | Iterator | Client and server scripts | Standard SuiteScript 2.0 object for iterating through results. |
PagedData.fetch(options) | query.Page | Client and server scripts | Retrieves a page in the set of pages included in the PagedData object. |
PagedData.fetch.promise(options) | Promise Object | Client and server scripts | Asynchronously retrieves a page in the set of pages included in the PagedData object. |
Properties
| Property Name | Type | Description |
|---|---|---|
PagedData.count | number (read-only) | The total number of paged query results. |
PagedData.pageRanges | query.PageRange[] | An array of page ranges for the set of paged query results. |
PagedData.pageSize | number (read-only) | The number of query result rows per page. |
Example Usage
To use the PagedData object effectively, you can set up a paginated query as follows:
1var myCustomerQuery = query.create({2 type: query.Type.CUSTOMER3});4myCustomerQuery.columns = [5 myCustomerQuery.createColumn({ fieldId: 'entityid' }),6 myCustomerQuery.createColumn({ fieldId: 'firstname' }),7 myCustomerQuery.createColumn({ fieldId: 'email' })8];9var myPagedResults = myCustomerQuery.runPaged({ pageSize: 10 });10 11// Fetch results using an iterator12var iterator = myPagedResults.iterator();13iterator.each(function(resultPage) {14 var currentPage = resultPage.value;15 var currentPagedData = currentPage.pagedData;16 log.debug(currentPage.pageRange.size);17 return true;18});In this example, a customer query is defined, executed, and results are iterated using the iterator() method of the PagedData object.
Who This Affects
This information is crucial for:
- Developers: Who need to handle paged data efficiently in their scripts.
- Administrators: Overseeing data management processes that involve paged queries.
Key Takeaways
- The PagedData object is vital for managing large datasets in SuiteScript 2.0.
- It includes methods for synchronous and asynchronous data retrieval.
- The object supports read-only properties for understanding query results.
Frequently Asked Questions (4)
How do I create a PagedData object in SuiteScript 2.0?
What is the maximum number of query results returned per page in PagedData?
Can I use the PagedData methods in both client and server scripts in SuiteScript 2.0?
What does the PagedData count property represent?
Was this article helpful?
More in SuiteScript
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- SuiteScript 2.x Sublist Values: Standard and Dynamic Mode
Use setSublistValue in standard mode; select a line, set its current value and commit it in dynamic mode. Choose the API from the record's mode.
- SuiteScript Record.setValue: Body Fields, Types and Errors
Set NetSuite body fields with Record.setValue, matching field IDs and value types and checking common API errors.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
