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

I tried this code, but it doesn’t work, still “INVALID_FLD_VALUE”. What should be the problem?


var startDate = format.format({type: format.Type.DATE, value: new Date(values.custrecord_startdate)}) ;

var endDate = format.format({type: format.Type.DATE, value: new Date(values.custrecord_bits_enddate)});

Rookie Answered on February 4, 2021.

Does your date object look correct when you log it?

on February 4, 2021.

Yup its correct. I found the solution. Need to convert the field  into a date field. I didn’t have to use format


newRecord.setValue(cfg.START_DATE, new Date(values.startdate));

on February 4, 2021.
Add Comment

Your Answer

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