Add components to the initial dataset

Note:

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

After you create your dataset components, you can add them to the dataset you created in Create an initial dataset.

In this step, you will add your dataset components to the initial dataset.

  1. In your script file, assign the columns you created to the Dataset.columns property. This property accepts an array of dataset.Column objects. Add the following code after the two dataset.createCondition(options) calls in Create conditions:

                  tutorialDataset.columns = [entityIdColumn, emailColumn, trandateColumn]; 
    
                
  2. Assign the conditions you created to the Dataset.condition property. This property accepts a single dataset.Condition object, which represents the set of all conditions for the dataset. We use dataset.createCondition(options) and the AND operator to combine the conditions you created earlier. Add the following code after you assign the columns above:

                  tutorialDataset.condition = dataset.createCondition({
        operator: 'AND',
        children: [inactiveCondition, trandateCondition]
    }); 
    
                

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
    });

    var inactiveColumn = dataset.createColumn({
        fieldId: 'isinactive'
    });
    var inactiveCondition = dataset.createCondition({
        column: inactiveColumn,
        operator: 'IS',
        values: [false]
    });
    var trandateCondition = dataset.createCondition({
        column: trandateColumn,
        operator: 'AFTER',
        values: ['3/3/2020']
    });

    tutorialDataset.columns = [entityIdColumn, emailColumn, trandateColumn];
    tutorialDataset.condition = dataset.createCondition({
        operator: 'AND',
        children: [inactiveCondition, trandateCondition]
    });
}); 

        

Related Topics

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

General Notices