dataset.createColumn(options)
Method Description |
Creates a dataset column based on a field or on a formula and a type. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Sibling Module Members |
|
Since |
2020.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
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. |
|
string |
required only if |
The field ID for the column (exclusive with formula/type). |
|
string |
required only if |
The formula for the column, such as ‘{email}’ or ‘{total} — {tax}’. |
|
optional |
The joined record on which the field is present. |
|
|
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. |
|
string |
optional |
The column label to display in the UI. |
|
string |
required only if |
The return type of the formula, such as ‘INTEGER’ or ‘STRING’. |
Errors
Error Code |
Thrown If |
---|---|
|
The |
|
Both the |
Syntax
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. Also see the Tutorial: Creating a Dataset Using the Workbook API topic.
// 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