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?

mmascitto Beginner Asked on March 18, 2020 in SuiteCloud.
Add Comment
2 Answers

Use setValue with a Date object as the value.
Use setText with a N/format module formatted string as the text.

Advanced Answered on March 18, 2020.

That worked. Thanks!

on March 18, 2020.

set text is not wokring… the vlaue is not being reflected

on December 21, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.