My brain is a bit mushy right now so I might be ov...
# suitescript
j
My brain is a bit mushy right now so I might be overlooking something, but I have a number that is a decimal e.g. 123.45. I need to store it in a field that's of type Integer. I'm getting an error even if I round and parseInt it, claiming that it's an "invalid field value" and showing a .0 at the end that shouldn't be there. I even get this if I try with a number without decimal points. Simple test:
Copy code
var test = 123;
ws.setValue({fieldId: 'custrecord_app_subtotal', value: test});
results in the error
You have entered an Invalid Field Value 123.0 for the following field: custrecord_app_subtotal
b
the guess is that NetSuite is confused. 5 and 5.0 are both the same thing as javascript is concerned. 5 and 5.0 are different for the Java backend
j
My experience with this error is, even though it's an integer field, you need to set the value as a string with the appropriate number of decimal places
Copy code
var test = 123;
ws.setValue({
  fieldId: 'custrecord_app_subtotal',
  value: test.toFixed(0) // '123'
});
Copy code
var test = 123.45;
ws.setValue({
  fieldId: 'custrecord_app_subtotal',
  value: test.toFixed(0) // '123'
});
j
I ended up having to use the format module with format.Type.INTEGER