PageRange Object Members in SuiteScript for Developers
The PageRange object in SuiteScript provides parameters for managing query results, enhancing how developers handle paginated queries.
The PageRange object in SuiteScript enables developers to better manage and navigate paginated query results efficiently. This object contains essential members that provide crucial information about the current page and its size, which are vital for handling larger datasets without degrading performance.
What Is the PageRange Object?
The PageRange object is used to represent a range of query results in a paginated manner within SuiteScript. It’s particularly useful when dealing with large datasets, allowing scripts to process data in chunks.
PageRange Object Members
The PageRange object includes the following members:
| Member Name | Return Type | Supported Script Types | Description |
|---|---|---|---|
PageRange.index | number (read-only) | Client and server scripts | Indicates the index for this page range. |
PageRange.size | number (read-only) | Client and server scripts | Specifies the number of query result rows in this page range. |
Supported Script Types
- Client Scripts: Scripts that run in the user’s browser.
- Server Scripts: Scripts that run on the NetSuite server.
How to Use the PageRange Object
To effectively utilize the PageRange object, developers can incorporate it in their paginated queries. Below is a sample script showcasing the implementation:
1// Add additional code2...3var myCustomerQuery = query.create({4 type: query.Type.CUSTOMER5});6myCustomerQuery.columns = [7 myCustomerQuery.createColumn({ fieldId: 'entityid' }),8 myCustomerQuery.createColumn({ fieldId: 'firstname' }),9 myCustomerQuery.createColumn({ fieldId: 'email' })10];11var myPagedResults = myCustomerQuery.runPaged({ pageSize: 10 });12 13// Fetch results using an iterator14var iterator = myPagedResults.iterator();15iterator.each(function(resultPage) {16 var currentPage = resultPage.value;17 var currentPageRange = currentPage.pageRange;18 log.debug(currentPageRange.size);19 return true;20});21 22// Alternatively, fetch results using a loop23for (var i = 0; i < myPagedResults.pageRanges.length; i++) {24 var currentPage = myPagedResults.fetch(i);25 var currentPageRange = currentPage.pageRange;26 log.debug(currentPageRange.size);27}28...29// Add additional codeThis code demonstrates how to create a customer query, specify columns, run paginated results, and retrieve the size of the current page range.
Key Benefits of Using PageRange
- Efficiency: Reduces memory usage by processing only a subset of results at a time.
- Performance: Improves response times for users when navigating large datasets.
- Flexibility: Provides robust options for developers to respond to various querying needs and complexities.
Conclusion
Utilizing the PageRange object enhances the efficiency of data management within SuiteScript, particularly when dealing with large queries. Understanding its members and how to implement them can significantly contribute to better script performance.
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- The
PageRangeobject helps manage paginated query results effectively. - Contains two main read-only properties:
indexandsize. - It supports both client and server scripts for flexible querying.
- Implementing it can lead to reduced memory usage and improved performance in scripts.
Frequently Asked Questions (4)
How do I retrieve the current page size using the PageRange object in SuiteScript?
What script types support the use of the PageRange object in SuiteScript?
Do I need any specific permissions to use the PageRange object in SuiteScript?
Can the PageRange object be used to navigate through all pages of a large dataset?
Was this article helpful?
More in Integration
- Natural Language Queries in NetSuite AI
MCP Standard Tools SuiteApp enables AI-driven data tasks in NetSuite, aligned with role permissions.
- Square Connector Integration in NetSuite 2026.1
Discover the Square Connector for seamless integration with NetSuite 2026.1, synchronizing transactions, orders, and inventory effortlessly.
- SuiteTalk Web Services Updates for NetSuite Integrations
SuiteTalk Web Services adds new Item Supply Plan support, enhancing integrations for efficient data management.
- SuiteTalk Web Services Enhancements in NetSuite
Explore the latest enhancements to SuiteTalk Web Services, improving integration and API functionalities in NetSuite.
Advertising
Reach Integration Professionals
Put your product in front of NetSuite experts who work with Integration every day.
Sponsor This Category