datasetLink.create(options)

Note:

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

Method Description

Links two datasets using a common column expression.

To link two datasets, both datasets must include a column that shares common data, such as a date. You use Dataset.getExpressionFromColumn(options) to obtain expressions for each column, then you specify these expressions (and the datasets they are part of) when you call datasetLink.create(options).

Returns

datasetLink.DatasetLink

Supported Script Types

Server scripts

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

Governance

None

Module

N/datasetLink Module

Sibling Module Members

N/datasetLink Module Members

Since

2021.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.datasets

dataset.Dataset[]

required

The datasets to link.

options.expressions

Array<workbook.Expression[]>

required

The column expressions to use to link the datasets.

options.id

string

optional

The ID of the linked dataset.

If you do not provide a value for this parameter, an ID is generated automatically and assigned to the DatasetLink.id property of the returned datasetLink.DatasetLink object.

Errors

Error Code

Thrown If

NO_DATASET_DEFINED

The value of the options.datasets parameter is an empty array.

Syntax

Important:

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

            // Add additional code
...
var myDatasetLink = datasetLink.create({
    datasets: [firstDataset, secondDataset],
    expressions: [[columnExpInFirstDataset, columnExpInSecondDataset]],
    id: 'myDatasetLinkId'
});
...
// Add additional code 

          

Related Topics

N/datasetLink Module
SuiteScript 2.x Modules
Dataset Linking in SuiteAnalytics Workbook

General Notices