Anyone know why I get this error when I feed in ne...
# suitescript
a
Anyone know why I get this error when I feed in new Date() as the value "{\"type\":\"error.SuiteScriptError\",\"name\":\"INVALID_FLD_VALUE\",\"message\":\"Invalid date value (must be M/D/YYYY)\"
b
that usually what happens when you dont pass in a Date as the value
whats the code you are using?
a
newRec.setValue({ fieldId: fieldName, value: new Date(value) });
b
and the value
a
Oh I think value is a string is that the problem?
"startdate": "02/26/2020"
b
if its not in iso-8601 format, its unlikely to work
where is the value coming from?
a
a post body
b
is it from a netsuite form and a date field?
a
no it's from postman
as raw JSON
b
if possible, use iso-8601 format for the string
a
okay I'll look into that format
b
its the format you would get using
Copy code
new Date().toISOString()
a
erhm now I get this "message": "org.mozilla.javascript.EcmaError: RangeError: Date is invalid.
b
whats the string used for the value
a
"2020-03-02"
b
use the full format (include date and time)
YYYY-MM-DDTHH:mm:ss.sssZ
a
yeah i tried that as the string and got this error: \"The field startdate contained more than the maximum number ( 10 ) of characters allowed.
b
Copy code
newRec.setValue({
  fieldId: "startdate",
  value: new Date("2020-03-02T21:36:03.591Z")
});
a
yeah I get it to work in the debugger
but it doesn't like this post function
Okay I'm an idiot it was some logic later in the loop trying to set the value again of startdate
it's working now 🙂 thanks