query.runSuiteQLPaged(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

Runs an arbitrary SuiteQL query as a paged query.

SuiteQL is a query language based on the SQL-92 revision of the SQL database query language. It provides advanced query capabilities you can use to access your NetSuite records and data.

You can specify the SuiteQL query as one of the following:

  • A string representation of the SuiteQL query

                            var results = query.runSuiteQLPaged({
        query: 'SELECT customer.entityid, customer.email FROM customer',
        pageSize: 10
    }); 
    
                          
  • A query.SuiteQL object

                            // To use this approach, you must load the N/util module in your script
    // In this example, mySuiteQLCustomerQuery is an existing SuiteQL object
    var pageSizeObject = {
        pageSize: 10
    };
    var results = query.runSuiteQL(util.extend(mySuiteQLCustomerQuery, pageSizeObject)); 
    
                          

    Although this approach is supported, you should create a query.SuiteQL object and call SuiteQL.runPaged(options), if possible, to run a paged SuiteQL query.

  • A JavaScript Object that contains a query property and, optionally, a params property

                            var results = query.runSuiteQL({
        query: 'SELECT customer.entityid, customer.email FROM customer WHERE customer.isperson = ?',
        params: [true], pageSize: 10
    }); 
    
                          
Important:

You cannot retrieve the columns (or column names) from the results of this method. If you need to refer to the columns used in the query, create a query.SuiteQL object, which contains the columns in the query in the SuiteQL.columns property. Then, pass the object to this method, or use SuiteQL.runPaged(options), to run the query.

Note:

If the SuiteAnalytics Connect feature is enabled in your NetSuite account, there is no limit to the number of results this method can return. If the SuiteAnalytics Connect feature is not enabled, this method can return a maximum of 100,000 results across all pages in the result set. For more information about SuiteAnalytics Connect, see SuiteAnalytics Connect.

For more information and examples of using SuiteQL in the N/query module, see SuiteQL in the N/query Module. For more information about SuiteQL in general, see SuiteQL.

Returns

query.PagedData

Important:

This method returns a maximum of 1000 pages.

Supported Script Types

Client and server scripts

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

Governance

10 units

Module

N/query Module

Sibling Module Members

N/query Module Members

Since

2020.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.query

string

required

The string representation of the SuiteQL query to run.

options.params

Array<string | number | boolean>

optional

The parameters to use in the SuiteQL query.

options.pageSize

number

optional

The size of each page in the query results. The default value is 50 results per page. The minimum page size is 5 results per page, and the maximum page size is 1000 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.

Errors

Error Code

Thrown If

MISSING_REQD_ARGUMENT

The parameter is missing.

SSS_INVALID_TYPE_ARG

Types other than string, number, or boolean are included in the options.params array.

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 results = query.runSuiteQLPaged({
        query: 'SELECT customer.entityid, customer.email FROM customer WHERE customer.isperson = ?',
        params: [true],
        pageSize: 20,
        customScriptId: 'myCustomScriptId'
    });
...
// Add additional code 

          

Related Topics

General Notices