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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category