Query.runPaged()
You must specify a sorting order in the query definition when using this method to avoid duplicate or missing results. The query definition must provide a unique and unambiguous sorting order with a specified precedence.
Method Description |
Executes the query and returns a query.PagedData object that represents the paged query results. You can iterate over this object to obtain each page of query results. For paged queries, the maximum number of result rows per page is 1000. The minimum number of result rows per page is 5, except for the last page in the result set (because the last page may include fewer than 5 results). |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
10 units |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2018.1 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
optional |
The size of each page in the query results. The default page size is 50 results per page. |
|
string |
optional |
A unique identifier used for potential performance issues in a query. If your query produces performance issues, the custom script ID identifies where the update will need to occur. This ID can also be used as a precaution to speed up performance fixes, if necessary.
Note:
The Script ID must be unique or the performance enhancements will affect each query with the same customScriptID. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/query Module Script Samples.
// Add additional code
...
var myTransactionQuery = query.create({
type: query.Type.TRANSACTION
});
var myEntityJoin = myTransactionQuery.autoJoin({
fieldId: 'entity'
});
myTransactionQuery.columns = [
myEntityJoin.createColumn({
name: 'subsidiary'
})
];
myTransactionQuery.sort = [
myTransactionQuery.createSort({
column: myTransactionQuery.columns[0],
ascending: false
})
];
var results = myTransactionQuery.runPaged({
pageSize: 10,
customScriptId: 'myCustomScriptId'
});
// Use the count property to count the search results easily
var resultCount = myTransactionQuery.runPaged({
pageSize: 10
}).count;
...
// Add additional code