This article is relevant if you are using SuiteScript 2.0 to submit a date field to NetSuite.
Background
The ability to submit a single field of data to a record is efficient. Date fields are generally tricky in NetSuite. You may be getting an error such as “You have entered an Invalid Field Value 3/24/2019 3:27 PM for the following field:” message.
What is the right syntax?
SuiteScript 2.0 to Submit a Single NetSuite Date Field
Here is some sample code to update a record on a custom table.
//assuming you are referencing the N/format module as "format", then this is how you get a NetSuite date string and submit it to the database var nsRefId = 33445 //record ID var dateStr = format.format({value: new Date(), type: format.Type.DATETIME}); record.submitFields({type: "customrecord_prolecto_bitcoin", id: nsRefId, values: {custrecord_prolecto_bitcoin_dts: dateStr}});
Work with Expert NetSuite Help
A thank you to our senior consultant, Boban, who offered this up to our team. If you enjoy the NetSuite Platform and want to be appreciated for the unique way you think and innovate, let’s have a conversation.
Please could you also give this for date time fields?
Hello Christopher,
This article is referencing a DateTime field. Am I confused?
Marty
Working with datetimes in Suitescript has been somewhat frustrating. I came across this article and this solution resulted in an error.
“type”:”error.SuiteScriptError”,”name”:”INVALID_FLD_VALUE”,”message”:”You have entered an Invalid Field Value 11/13/2024 11:26:00 am for the following field:
I have found in my experience the only way to get a datetime field to submit in SS2x is to use a date object instead of any kind of string.