Using SuiteQL with the N/query Module in SuiteScript
You can use SuiteQL to query your NetSuite data using the N/query module in SuiteScript. The following object and methods are available in the N/query module to work with SuiteQL:
-
The query.SuiteQL object represents a SuiteQL query. It includes properties that represent the query type, the SuiteQL string representation of the query, result columns to return from the query, and any additional parameters the query requires. You can use SuiteQL.run() to run the query as a non-paged query or SuiteQL.runPaged(options) to run the query as a paged query.
-
The Query.toSuiteQL() method converts an existing query (as a query.Query object) to its SuiteQL representation (as a query.SuiteQL object).
-
The query.runSuiteQL(options) and query.runSuiteQLPaged(options) methods let you run an arbitrary SuiteQL query. You can specify this query as a SuiteQL string, query.SuiteQL object, or generic JavaScript Object containing a required
query
property and an optionalparams
property.
If the SuiteAnalytics Connect feature is enabled in your NetSuite account, there is no limit to the number of results these methods can return. If the SuiteAnalytics Connect feature is not enabled, these methods can return a maximum of 100,000 results across all pages in the result set. For more information about SuiteAnalytics Connect, see SuiteAnalytics Connect.
Here is an example of how to load an existing query, convert it to SuiteQL, and run it:
var myLoadedQuery = query.load({ id: 'custworkbook237'
}); var mySuiteQLQuery = myLoadedQuery.toSuiteQL();
var myResultSet = mySuiteQLQuery.run();
For more information, see SuiteQL in the N/query Module.
For a list of supported functions, see SuiteQL Supported and Unsupported Functions and SuiteQL Supported Built-in Functions.