Query Object Members for SuiteScript 2.1 Integration
Query object members in SuiteScript enable flexible data retrieval through various methods, conditions, and joins.
Starting with the Query object in SuiteScript, developers can create complex data retrieval requests efficiently. This functionality is critical for customizing data access in applications and streamlining operations.
What Are Query Object Members?
The query.Query object provides developers with a structured way to construct queries in SuiteScript. This object is central to the N/query module and offers various members that facilitate data interactions. Below is an overview of the key members available for the query.Query object:
Methods
| Method | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|
Query.and(conditions) | query.Condition | Client and server scripts | Creates a new condition that represents a logical conjunction (AND) of provided conditions. |
Query.autoJoin(options) | query.Component | Client and server scripts | Automatically creates a join relationship based on record types. |
Query.createColumn(options) | query.Column | Client and server scripts | Generates a result column based on the initial query object. |
Query.createCondition(options) | query.Condition | Client and server scripts | Defines a condition for the initial query object. |
Query.createSort(options) | query.Sort | Client and server scripts | Establishes a sort order based on specified query result columns. |
Query.join(options) | query.Component | Client and server scripts | Defines a join relationship; an alias for Query.autoJoin(options). |
Query.run(options) | query.ResultSet | Client and server scripts | Executes the query and returns the results. |
Query.toSuiteQL() | query.SuiteQL | Client and server scripts | Converts the query object to its SuiteQL representation. |
Properties
| Property | Return Type | Description |
|---|---|---|
Query.child | Object (read-only) | A reference to the child components of the query. |
Query.columns | query.Column[] | An array of columns returned from the query. |
Query.condition | query.Condition | The main condition that filters the returned results. |
Query.id | number (read-only) | The unique identifier for the query, available for loaded queries. |
Query.name | string (read-only) | The name of the query, available for loaded queries. |
Query.root | query.Component (read-only) | The root component of the query definition. |
Query.sort | query.Column[] (read-only) | An array of columns used for sorting. |
How to Use the Query Object
To utilize the query.Query object effectively:
- Create a Query Definition: Use
query.create(options)to initiate a new query. - Define Conditions: Utilize methods like
Query.createCondition(options)to set up filters. - Add Joins: Employ
Query.autoJoin(options)to manage relationships between different record types. - Execute the Query: Finally, run the query using
Query.run(options)or access it asynchronously withQuery.run.promise().
Key Considerations
When working with the Query object, consider the following best practices:
- Ensure all conditions and columns are defined before executing a query.
- Leverage the automatic join capabilities to simplify code and reduce errors.
- Familiarize yourself with the
query.Conditionstructure to create more complex filters easily.
Key Takeaways:
- The
query.Queryobject is essential for building complex retrieval queries in SuiteScript. - Understanding its methods and properties can significantly enhance data interaction capabilities.
- Utilize auto-joins and async execution options for efficient scripts.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
What script types support the Query object methods in SuiteScript?
How can I define conditions for a query in SuiteScript using the Query object?
Does the Query object in SuiteScript support converting queries to SuiteQL?
Can I use the Query object to automatically create join relationships in SuiteScript?
Was this article helpful?
More in General
- Payment Date Prediction Feature in NetSuite
Payment Date Prediction in NetSuite utilizes machine learning to enhance financial planning by predicting invoice payment dates.
- NetSuite Ship Central Enhancements for Packing & Shipping
NetSuite Ship Central features enhance packing and shipping operations for improved efficiency and accuracy.
- New Role Setup for NetSuite AI Connector Service in 2026.1
The 2026.1 release adds a new role requirement for the NetSuite AI Connector Service, streamlining custom tool development.
- Generative AI Features in NetSuite 2026.1
Discover new generative AI features in NetSuite 2026.1, enhancing reporting, search, predictions, and development productivity.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category