Is it possible that a Javascript node, executes code stored in a table

I have a table with three fields: year,period (both integer) and a stringfield called jcode.

For each record the jcode is different (adding sometimes year and period/100 and sometimes year+2*period/100.

I feed the table to a javascript node and in the custom code I place outresult=c_jcode (outresult is of type string), but the code is not evaluated.

Can this be done in KNIME?

Hi RAPosthumus, 

I guess you mean the Generic Java Script node. Yes, it is possible to use input data in your JavaScript code. For that in your code you will need to loop through the input data and copy it to a list or an object in order to be able to use it later in your code. An example: 


// Dataset holding the table
var dataset = [];
// Push column headers
dataset.push(['Address', 'Name']);
// Dataset holding a single row
var rowDataset = [];
// Iterate over table and fill dataset
var rows = knimeDataTable.getRows();
for (var rowID = 0; rowID < knimeDataTable.getNumRows(); rowID++) {
    var row = rows[rowID];
    rowDataset = [];
    for (var colID = 0; colID < knimeDataTable.getNumColumns(); colID++) {

Please check the example workflow on the EXAMPLES server: knime://EXAMPLES/_Old Examples (2015 and before)/018_Views and JavaScript/018001_Generic JS View - GoogleCharts and D3 for more details. 




Great answer, thanks!