What about Number() instead of parseInt()
# suitescript
a
What about Number() instead of parseInt()
c
Number gives the same error. Oddly though this works:
Copy code
Number(data.id).toString()
a
Then that data.id is coming with some weird character that you don't even see, Number() would get rid of that and toString() is going to normalize it...
It should work with string without any problem.
c
What character could there possibly be? Number() yields NaN for any non numeric character AFAIK
a
console.log(Number('12345 '))
console.log(Number('12345 \n'))
console.log(Number('12345 \r'))
c
I see, but the output of that is still 12345 as an integer. Why would toString() be needed?
a
options.id number | string | required | The internal ID of the existing record instance in NetSuite.
15011.0 this is not the same as the output of Number... if Number() output is 15011 and still errors out, then is just because it is NetSuite...
I would take Number() over parseInt() any day...
💯 1
c
Sure no problem with using Number() but it’s odd that that the output of that still gives the error. I’ll chalk it up to a netsuite bug.
a
This is one of the reason I don't like parseInt: console.log(parseInt(0.05)) // 0 console.log(parseInt(0.005)) // 0 console.log(parseInt(0.0000005)) // 5 On top of that you would face radix issues too if you don't specific the radix.
c
Good to know. Thanks
s
I tend to avoid
submitFields
altogether unless it's really needed for performance.