Create columns

Note:

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

Columns represent the record fields that are included in the dataset. Column definitions are used to create conditions that apply to the corresponding fields in the dataset.

In this step, you will create objects to represent columns for the dataset.

  1. In your script file, create a column using dataset.createColumn(options). This column represents the entityid field on the root customer record type. Add the following code after the two dataset.createJoin(options) calls in Create joins with other record types:

                  var entityIdColumn = dataset.createColumn({
        fieldId: 'entityid'
    }); 
    
                

    The dataset.createColumn(options) method returns a dataset.Column object.

  2. Create a second column to represent the email field on the joined employee record type. Add the following code after the first dataset.createColumn(options) call:

                  var emailColumn = dataset.createColumn({
        fieldId: 'entityid',
        join: salesRepJoin
    }); 
    
                
  3. Create a third column to represent the trandate field (transaction date) on the joined transaction record type. Add the following code after the second dataset.createColumn(options) call:

                  var trandateColumn = dataset.createColumn({
        fieldId: 'trandate',
        join: transactionJoin
    }); 
    
                

At this point, your script file should look similar to the following:

          require(['N/dataset'], function(dataset) {
    var tutorialDataset = dataset.create({
        type: 'customer'
    });

    var salesRepJoin = dataset.createJoin({
        fieldId: 'salesrep'
    });
    var transactionJoin = dataset.createJoin({
        fieldId: 'entity',
        source: 'transaction'
    });

    var entityIdColumn = dataset.createColumn({
        fieldId: 'entityid'
    });
    var emailColumn = dataset.createColumn({
        fieldId: 'entityid',
        join: salesRepJoin
    });
    var trandateColumn = dataset.createColumn({
        fieldId: 'trandate',
        join: transactionJoin
    });
}); 

        

SuiteAnalytics Workbook UI

In the SuiteAnalytics Workbook UI, each included column (field) is highlighted at the top of the Fields list. You can also see each field as a column heading in the Data Grid.

Included fields in a dataset.

Related Topics

Prerequisites
Create an initial dataset
Create joins with other record types
Create conditions
Add components to the initial dataset
Save and run the dataset
Tutorial: Creating a Dataset Using the Workbook API

General Notices