Query.runPaged(options)

Important:

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

query.PagedData

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/query Module

Parent Object

query.Query

Sibling Object Members

Query Object Members

Since

2018.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.pageSize

string

optional

The size of each page in the query results.

The default page size is 50 results per page.

options.customScriptId

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.

options.metaDataProvider

string

optional

Indicates whether the query should fail if you lack the necessary permissions for some fields or records.

If set to SUITE_QL:

The query fails if you attempt to access fields or records without the necessary permissions.

If set to STATIC:

The query succeeds even if you lack permissions for some fields or records, but it does not return any data for those fields or records.

Defaults to SUITE_QL.

Syntax

Important:

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 

          

Related Topics

General Notices