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
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.
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!