Pentaho/Kettle Javascript: Calling a field dynamically -


i'm trying retrieve value of field need name of field built dynamically.

imagine have people born day in last year in columns named day number. have columns day_1, day_2, day_3 , on. , values 5, 12, 33... want loop on values , built field name dinamycally:

var column_name = "day_"+i

so later on can loop increasing 1 one.

problem javascript not recognize day_i valid input field cannot retrieve value of field, pentaho handles string.

in javascript step there array variable row. can lookup index of column using getinputrowmeta().indexofvalue("day_" + i) , use index value of field in current row:

var column_name = "day_" + i; var column_index = getinputrowmeta().indexofvalue(column_name); var column_value = row[column_index]; 

please note, column_value reference object of java type (e.g. java.lang.string), javascript string methods not work on value. need convert value javascript type or use java methods.


Comments