RE: Formatting Error When Setting Date Field
Hi, when I’m writing a server side script, I seem to always have trouble setting new Date() on a field. The error I get says the format is wrong:
{“type”:”error.SuiteScriptError”,”name”:”INVALID_FLD_VALUE”,”message”:”Invalid date value (must be M/D/YYYY)”,”stack”:
But I’m formatting it using the format API and when I log my variable it’s ‘3/18/2020’, seemingly the correct format. The odd thing is I only get this error when using record.setValue(). When I do record.submitFields(), it’s fine.
Any suggestions on how to fix this?
Use setValue with a Date object as the value.
Use setText with a N/format module formatted string as the text.
That worked. Thanks!
set text is not wokring… the vlaue is not being reflected