List All Datasets and Load the First Dataset

The following sample lists all existing datasets and then loads the first dataset.

Note:

This sample script uses the require function so you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (a script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
 * @NApiVersion 2.x
 */

// The following script lists all existing datasets and then loads the first dataset.

require(['N/dataset'], function(dataset){ 
    // List all created datasets
    var allDatasets = dataset.list();
    log.audit({
        title: 'All datasets:',
        details: allDatasets
    });
    
    // Load the first dataset
    var myFirstDataset = dataset.load({
        id: allDatasets[0].id
    });
    log.audit('myFirstDataset:', myFirstDataset);
}); 

        

General Notices