Create joins with other record types

SuiteAnalytics Workbook enables you to add fields from multiple record types to a single dataset. This includes record types that are more than one join away from the root record type of a dataset, enabling you to compile workbook source data from a diverse set of record types.

In this step, you will create objects to represent joins with other record types from the root record type.

  1. In your script file, create a join using dataset.createJoin(options). This join connects the root record type (customer) with the employee record type using the salesrep field. The salesrep field is located on the customer record. Add the following code after you define the dataset name and description in Create an initial dataset:

                  var salesRepJoin = dataset.createJoin({
        fieldId: 'salesrep'
    }); 
    
                

    The dataset.createJoin(options) method returns a dataset.Join object.

  2. Create a second join to connect the root record type (customer) with the transaction record type using the entity field. The entity field on the transaction record type refers to the customer associated with that transaction. However, there is no join field on the customer record type that refers to the transactions for that customer.

    To represent this relationship as a join object, you must specify the source parameter as well as the fieldId parameter. The source parameter refers to the record type to join from (transaction), and the fieldId parameter refers to the field on that record type to use for the join (entity). Add the following code after the first dataset.createJoin(options) call:

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

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

        

SuiteAnalytics Workbook UI

In the SuiteAnalytics Workbook UI, joined fields in a dataset are listed when you click a joined record type in the Records list. They are highlighted and appear at the top of the Fields list.

A joined field in a dataset.

Related Topics

General Notices