OmniJS: Read number from column


#1

I’m trying to write a script which will do some math on values from 3 columns and store it in a 4th column. I’ve got pretty much everything in place but fail at calculating the said expression - it always gives NaN as the result.

After some investigation, it turns out that the script fails to correctly read data obtained using the valueForColumn method.

Example:

var val = item.valueForColumn(col)
< undefined
val
< [object Decimal: 1]
var res = val * 5
< undefined
res
< NaN
Number(val)
< NaN

How do I obtain the numerical value correctly?


#2

What kind of value are you binding to the name col ?

(It needs, of course, to be a reference to a (numeric) column object, rather than any kind of column name or id string, so the value of col needs to be derived by an expression of the form:

document.outline.columns.byTitle('Costs')

)

But probably easier if you paste as much of your code as you can here, so that we can see what’s really going on.


#3

All seems to be working here:

49


#4

parseInt / parseFloat did the trick! I was expecting some kind of an automatic type conversion to happen, was not aware that one needs to use string as an intermediate type! Thanks a lot!


#5
var res = val.multiply(Decimal.fromString('5'))

but I think it’s not the best solution…