invalid date value (must be D/M/YYYY) even though ...
# ask-stanley-ai
n
invalid date value (must be D/M/YYYY) even though the date is 13/5/2026 and the expdate is a dynamic changing date but for example it could be 13/5/2026 and when i use this expDate = format.format({ value: expDate, type: format.Type.DATE }); it returns Invalid type NaN, use Date
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like the issue is related to the way you're setting the date value in NetSuite. The
setValue
method expects a Date object, not a string. When you use
format.format
, it returns a string, which is not what
setValue
is expecting. Here's a corrected version of your code:
Copy code
javascript
let expDate = new Date();
expDate.setDate(expDate.getDate() + 1); // or whatever logic you have to set the date

purchaseReq.setValue({
    fieldId: 'duedate',
    value: expDate
});
In this code,
expDate
is a Date object, which is the correct type for the
setValue
method. Also, please note that the date format
D/M/YYYY
is not recognized by JavaScript's Date object. JavaScript expects dates in the format
MM/DD/YYYY
. If your date is in a different format, you'll need to convert it to the expected format before creating the Date object. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83145
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826563239
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824230254
Please provide your feedback on this answer.