Column Object Members

Explore the available members of the Column object in SuiteScript, enhancing query functionality for NetSuite API users.

·3 min read·View Oracle Docs

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 NameTypeSupported Script TypesDescription
Column.aggregatestring (read-only)Client and server scriptsAn aggregate function that performs calculations on column values, returning a single result.
Column.aliasstring (read-only)Client and server scriptsAn alternate name for a column used in mapped results.
Column.componentquery.Component (read-only)Client and server scriptsReferences the query.Component object associated with this column.
Column.contextObject (read-only)Client and server scriptsDetermines the field context for displayed values in the column.
Column.fieldIdstring (read-only)Client and server scriptsThe identifier for the query result column; cannot be set simultaneously with the Column.formula property.
Column.formulastring (read-only)Client and server scriptsThe formula used to generate the query result column; cannot be set simultaneously with Column.fieldId.
Column.groupBy(read-only)Client and server scriptsIndicates whether the results are grouped by this column.
Column.labelstring (read-only)Client and server scriptsThe display label for the column.
Column.typestring (read-only)Client and server scriptsIndicates 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 with Query.autoJoin(options) or Component.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:

suitescript
1var myCustomerQuery = query.create({
2 type: query.Type.CUSTOMER
3});
4var myAggColumn = myCustomerQuery.createColumn({
5 fieldId: 'amount',
6 aggregate: query.Aggregate.AVERAGE
7});
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.Column object 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?
No, a Column object cannot simultaneously have the 'formula' and 'fieldId' properties set. You must choose one or the other to define your query result column.
How do I ensure my query columns are recognized during execution in SuiteScript?
Assign all created columns to the 'Query.columns' property. This step is crucial for the columns to be recognized during the execution of your query.
Are the column members applicable for both client and server side scripts?
Yes, the column object members such as 'aggregate', 'alias', and others are supported for both client and server side scripts in NetSuite.
Is it necessary to include a 'query.Column' object in every query definition?
Yes, including at least one 'query.Column' in your query definition is critical to prevent scripting errors, even though it is technically an optional parameter.
Source: Column Object Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in General

View all General articles →