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 optional params property.

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();

Leave a comment

Your email address will not be published. Required fields are marked *