N/query Module Members in SuiteScript for NetSuite
The N/query module in SuiteScript provides members for querying data. This includes creating query definitions, conditions, and handling result sets.
The N/query module in SuiteScript serves as an interface for constructing database queries within NetSuite. With various object members and methods, developers can efficiently retrieve and manipulate data. Understanding these components is crucial for leveraging the full power of SuiteScript in query operations.
What Are N/query Module Members?
The N/query module includes several members that facilitate the creation and handling of database queries. Here’s a breakdown of its key components:
| Member Name | Type | Return Type | Description |
|---|---|---|---|
query.Column | Object | Object | Represents a column in the query result set. Use to define query fields. |
query.Component | Object | Object | Represents a component in the query definition, including relationships for joins. |
query.Condition | Object | Object | A condition to filter query results. |
query.Page | Object | Object | Represents a single page of paged query results. |
query.PagedData | Object | Object | Encapsulates a set of paged query results. |
query.Query | Object | Object | The overall query definition. |
query.Result | Object | Object | Represents a row of results from the query. |
query.ResultSet | Object | Object | The collection of results returned by the query. |
query.Sort | Object | Object | Specifies the sorting criteria for the query results. |
query.SuiteQL | Object | Object | Allows executing SuiteQL based queries. |
Key Methods of the N/query Module
Supporting the functionality of the module are several important methods:
- Creating Queries: Use
query.create(options)to define the query structure. This method requires at least one column to be defined. - Loading Existing Queries: Utilize
query.load(options)to load queries created in the SuiteAnalytics Workbook UI for modification and execution. - Running Queries: The
query.runSuiteQL(options)method allows executing arbitrary SuiteQL queries directly, returning the results according to specified parameters.
Important Considerations
- Essential Column Requirement: At least one
query.Columnobject must be present in every query definition to avoid scripting errors. It is essential for data retrieval and manipulation within SuiteScript. - Script Compatibility: All components of the N/query module support both client and server scripts, offering flexibility in how scripts are deployed and executed within NetSuite.
Example Usage
1var myCustomerQuery = query.create({2 type: query.Type.CUSTOMER3});4 5myCustomerQuery.columns = [6 myCustomerQuery.createColumn({7 fieldId: 'internalid'8 }),9 myCustomerQuery.createColumn({10 fieldId: 'entityid'11 })12];13 14var results = myCustomerQuery.run();This code demonstrates the creation of a customer query and retrieval of selected columns' data.
Key Takeaways
- The N/query module provides comprehensive tools for data query operations in SuiteScript.
- Key members and methods include
query.Column,query.Condition, and several methods for query execution. - Valid usage of the module requires understanding the components and their relationships.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
Does the N/query module support both client and server scripts in NetSuite?
What is a mandatory component when creating a query with the N/query module?
How can I execute a SuiteQL query using the N/query module?
Is it possible to load and modify existing queries created in the SuiteAnalytics Workbook UI?
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