Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

NetSuite Tip: How to Submit a Date Field with SuiteScript 2.0

NetSuite Technical



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.

Marty Zigman LinkedIn

Marty Zigman

Holding three official certifications, Marty is widely recognized as a top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. A former Deloitte & Touche CPA and technology executive with CTO roles, he brings over 35 years of leadership in ERP, CRM, and eCommerce business systems. Contact Marty to engage directly.

BiographyYouTubeLinkedInX (Twitter)

4 thoughts on “NetSuite Tip: How to Submit a Date Field with SuiteScript 2.0

  1. 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.

    Reply
  2. I am with Kyle here. I received the same error message using format.format(). I also had to pass just a Javascript Date() to get it working.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *