Aaron McCausland
04/22/2025, 7:18 PMYou have entered an Invalid Field Value 4/22/2025 2:15:15 pm for the following field...
Celigo AI
04/22/2025, 7:18 PMAI generated answer (using internal Slack threads):The difference in behavior between SuiteScript 1.0 and SuiteScript 2.x when setting a Date/Time field value is due to the different ways these two versions handle date and time values. In SuiteScript 1.0, the
nlapiSetFieldValue
function is more lenient and allows you to set a Date/Time field with a string value in the format "M/D/YYYY hmmss a".
However, in SuiteScript 2.x, the Record.setValue
method is stricter and expects a JavaScript Date object, not a string. If you try to set a Date/Time field with a string value, it will throw an error saying "You have entered an Invalid Field Value... for the following field...".
To resolve this issue in SuiteScript 2.x, you need to convert your string value to a JavaScript Date object before setting the field value. Here is an example of how you can do this:
javascript
var dateString = "4/22/2025 2:15:15 pm";
var dateObject = new Date(dateString);
record.setValue({
fieldId: 'yourDateFieldId',
value: dateObject
});
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/22/2025, 7:18 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.862119138
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851117313
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.850428939
Celigo AI
04/22/2025, 7:18 PM