[Javascript]Deprived Column With Record Total

This recipe demonstrates how to calculate the record total number in deprived column using javascript in a composite datasource.

Steps taken:

  1. Create a composite datasource (FruitSales_CP.ds):
  2. Drag and drop FruitSales.ds as the beginning of the flow.
  3. Add a “Processor” element following the tabular datasource. Select “General > JavaScript”. Enter the following script in “startData” page:var count=0;
    var total=0;
    var dataArray = new Array();
    next.startData(this);Enter the following script in “processRecord” page:dataArray.push(Fruit);
    count++;Enter the following script in “endData” page:{for ( x in dataArray)
    {
    var out = this.newRecordInstance();
    var outData = out.getData();
    outData[0] = dataArray[x];
    outData[1] = count;
    next.processRecord(out);

}
}
next.endData(this);
2. Create another composite datasource (data_cmp.ds):

  1. Drag and drop data.ds as the beginning of the flow.
  2. Add a “Processor” element” following the tabular datasource. Select “General > Script”. Enter the following script in “startData” page:next.startData(this);
    var dataArray = new Array();Enter the following script in “processRecord” page:dataArray.push(Name1);
    count++;Enter the following script in “endData” page:{
    var out = this.newRecordInstance();
    var outData = out.getData();for ( x in dataArray )
    {
    outData[0] = dataArray[x];
    outData[1] = count;
    next.processRecord(out);
    }
    }
    next.endData(this);

To download the necessary files for this recipe, refer to the attached ZIP package.
DeprivedColumnWithRecordTotal.zip