Create an initial dataset

Note:

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

Datasets are the basis for all workbooks in your account. In a dataset, you combine the fields of a root record type and any joined related record types to create a query. You can also create custom formula fields to calculate values that are not available through standard record type fields.

In this step, you will create an initial dataset object that uses the customer record type as the root record type.

  1. Create a new file in a text editor of your choice. If your text editor is able to provide syntax highlighting based on file type, select JavaScript (.js) file highlighting.

  2. Add the following code to load the N/dataset module:

                  require(['N/dataset'], function(dataset) {
    
    }); 
    
                

    In this tutorial, you load only the N/dataset module. However, when you work with datasets and workbooks in your production account, you should always load both the N/dataset and N/workbook modules in your scripts. This approach ensures that you can access all workbook-related objects and methods.

  3. Create a dataset using dataset.create(options). Use the type parameter to specify the root record type for the dataset. Add the following code inside the require function definition:

                  var tutorialDataset = dataset.create({
        type: 'customer'
    }); 
    
                

    This method returns a dataset.Dataset object. The string customer is the name of the customer record type. When you create a dataset, you must specify the name of the root record type to use. To obtain this name (as well as other record and field names), you can use the Records Catalog. For more information, see Records Catalog Overview.

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

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

        

SuiteAnalytics Workbook UI

In the SuiteAnalytics Workbook UI, the root record type for a dataset appears in the info popup beside the dataset name.

The root record type for a dataset.

Related Topics

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

General Notices