Column Object Members
Explore the available members of the Column object in SuiteScript, enhancing query functionality for NetSuite API users.
The query.Column object in SuiteScript provides crucial members for defining query result columns in NetSuite. Understanding these members is essential for developers who want to effectively retrieve and manipulate data through queries.
What Are Column Object Members?
Column object members allow you to customize query definitions significantly. Each member of a query.Column provides different capabilities, enhancing how data is aggregated, displayed, and managed within your scripts.
Column Object Members
The following table summarizes the members available for a query.Column object:
| Member Name | Type | Supported Script Types | Description |
|---|---|---|---|
Column.aggregate | string (read-only) | Client and server scripts | An aggregate function that performs calculations on column values, returning a single result. |
Column.alias | string (read-only) | Client and server scripts | An alternate name for a column used in mapped results. |
Column.component | query.Component (read-only) | Client and server scripts | References the query.Component object associated with this column. |
Column.context | Object (read-only) | Client and server scripts | Determines the field context for displayed values in the column. |
Column.fieldId | string (read-only) | Client and server scripts | The identifier for the query result column; cannot be set simultaneously with the Column.formula property. |
Column.formula | string (read-only) | Client and server scripts | The formula used to generate the query result column; cannot be set simultaneously with Column.fieldId. |
Column.groupBy | (read-only) | Client and server scripts | Indicates whether the results are grouped by this column. |
Column.label | string (read-only) | Client and server scripts | The display label for the column. |
Column.type | string (read-only) | Client and server scripts | Indicates the return type of the formula for the column. |
How to Create Columns
To create columns in your queries, you can utilize the following methods:
- Use
Query.createColumn(options)to create a column in a standard query definition. - Use
Component.createColumn(options)for columns in join relationships created withQuery.autoJoin(options)orComponent.autoJoin(options).
It is essential to assign all created columns to the Query.columns property to ensure they are recognized during execution.
Example Syntax
Here’s a basic example of how to define a query and utilize column members:
1var myCustomerQuery = query.create({2 type: query.Type.CUSTOMER3});4var myAggColumn = myCustomerQuery.createColumn({5 fieldId: 'amount',6 aggregate: query.Aggregate.AVERAGE7});8myCustomerQuery.columns = [myAggColumn];9var theAggregate = myAggColumn.aggregate;Important Note
Including at least one query.Column in your query definition is critical to avoid scripting errors. Although it is an optional parameter when using the query.create(options) method, a Column object must be present for each query definition.
Who This Affects
This content is particularly relevant for:
- Developers: Implement and manage queries effectively.
- Administrators: Understand how to customize and extend data retrieval processes in NetSuite.
Key Takeaways
- The
query.Columnobject is vital for querying data in SuiteScript. - Multiple members provide functionalities for aggregation, aliases, and data context.
- Properly defining columns helps in error prevention and enhances query performance.
Frequently Asked Questions (4)
Can a single column in a NetSuite query have both a formula and a fieldId set?
How do I ensure my query columns are recognized during execution in SuiteScript?
Are the column members applicable for both client and server side scripts?
Is it necessary to include a 'query.Column' object in every query definition?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
