dataset.createColumn(options)

Note:

The content in this help topic applies to SuiteScript 2.x.

Method Description

Creates a dataset column based on a field or on a formula and a type.

Returns

dataset.Column

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/dataset Module

Sibling Module Members

N/dataset Module Members

Since

2020.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.alias

string

optional

The alias for the column. This can be used to get the expression for the column which can be used in a workbook. Use Dataset.getExpressionFromColumn(options) to get the expression.

options.fieldId

string

required only if options.formula and options.type are not specified

The field ID for the column (exclusive with formula/type).

options.formula

string

required only if options.fieldId is not specified

The formula for the column, such as ‘{email}’ or ‘{total} — {tax}’.

options.join

dataset.Join

optional

The joined record on which the field is present.

options.id

number

optional

The ID of the column. This can be used to get the corresponding expression for the column which can be used in a workbook. Use Dataset.getExpressionFromColumn(options) to get the expression.

options.label

string

optional

The column label to display in the UI.

options.type

string

required only if options.fieldId is not specified

The return type of the formula, such as ‘INTEGER’ or ‘STRING’.

Errors

Error Code

Thrown If

INVALID_FORMULA_TYPE

The options.type parameter is invalid.

MUTUALLY_EXCLUSIVE_ARGUMENTS

Both the options.formula and options.fieldId parameters are specified. Or both the options.formula and options.join parameters are specified.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/dataset Module Script Samples.

            // Add additional code
...
// Create a field column
var myFieldColumn = dataset.createColumn({
    fieldId: 'name',
    name: 'My Field Column'
});
// Create a formula/type column
var myFormulaColumn = dataset.createColumn({
    formula: '{email}',
    type: 'STRING',
    id: 11,
    label: 'My Formula Column'
});
// Create a join column
var myJoinColumn = dataset.createColumn({
    fieldId: 'name',
    join: myJoin  // Create this using dataset.createJoin
});
...
// Add additional code 

          

Related Topics

N/dataset Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices