When working with code, it's almost certain you will come across an error message in your day-to-day work. But just receiving an error message isn’t necessarily a cause for panic. A common error seen in SuiteScript 2.0 is a date type of field error.
To give you an example of this error, say you are working on code that simply sets a date field, like this one:
At a glance, everything looks fine, until you encounter one of NetSuite’s surprise error messages like below:
So why is this happening? There are two main reasons. We’ve broken them down for you below.
Unlike SuiteScript 1.0, SuiteScript 2.0 has stricter rules on setting the date and datetime type of fields. For date type of field, the solution is to use the format.parse method as shown below:
For client-side and user event scripts, format.parse respects the user preferences from Home > Set Preferences. For scheduled scripts and map/reduce scripts, this method follows the company preferences from Setup > Company > General Preferences.
This could be the source of your troubles even if you may have already included the format.parse method, but you didn’t properly follow what’s in your date format preferences.
A good example is when the user preferences show DD/MM/YYYY as the Date Format preference, but the value set by the script was: 09/20/2018 (e.g., MM/DD/YYYY). This wouldn’t work since the date format must be in the correct order..
To solve this, you must ensure that the output shows 20/09/2018.
With ServiceRocket, you’ll get certainty, expertise and success built into your NetSuite implementation, configuration and custom development. When you work with us, you get access to NetSuite-trained Certified Developers with over 400+ NetSuite scripts and 50+ Suitelet workflows combined. Rest assured that ServiceRocket will help you find success and provide you with the opportunities you need to transform your business.
Do you have NetSuite license management, implementation, administration, support or custom development needs? We’ve got your back! Contact our NetSuite Certified Experts today.
Ensure the highest return on your NetSuite investment with our custom development or administrative services.