PagedData Object Members in SuiteScript 2.0

PagedData object in SuiteScript 2.0 offers methods and properties for handling paged query results efficiently.

·2 min read·View Oracle Docs

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 NameReturn TypeSupported Script TypesDescription
PagedData.iterator()IteratorClient and server scriptsStandard SuiteScript 2.0 object for iterating through results.
PagedData.fetch(options)query.PageClient and server scriptsRetrieves a page in the set of pages included in the PagedData object.
PagedData.fetch.promise(options)Promise ObjectClient and server scriptsAsynchronously retrieves a page in the set of pages included in the PagedData object.

Properties

Property NameTypeDescription
PagedData.countnumber (read-only)The total number of paged query results.
PagedData.pageRangesquery.PageRange[]An array of page ranges for the set of paged query results.
PagedData.pageSizenumber (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:

suitescript
1var myCustomerQuery = query.create({
2 type: query.Type.CUSTOMER
3});
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 iterator
12var 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.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

How do I create a PagedData object in SuiteScript 2.0?
A PagedData object can be created using the methods `Query.runPaged(options)` or `Query.runPaged.promise(options)`. These methods return a PagedData object which can manage paged query results.
What is the maximum number of query results returned per page in PagedData?
The PagedData object can return up to 1000 query results per page.
Can I use the PagedData methods in both client and server scripts in SuiteScript 2.0?
Yes, methods like `PagedData.iterator()`, `PagedData.fetch()`, and `PagedData.fetch.promise()` are supported in both client and server scripts.
What does the PagedData count property represent?
The `PagedData.count` property represents the total number of paged query results and is read-only.
Source: PagedData 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 Integration

View all Integration articles →