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 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 format of the date being used. In NetSuite, when setting a date value, it expects a Date object, not a string. If you are using the
format.format
function, it will return a string, which is not what the
setValue
function expects. Here is a corrected version of your code:
Copy code
javascript
let expDate = new Date('2026-05-13');
expDate = format.format({
    value: expDate,
    type: format.Type.DATE
});
However, if you are trying to set a date field, you should pass a Date object directly, like this:
Copy code
javascript
let expDate = new Date('2026-05-13');
purchaseReq.setValue({
    fieldId: 'duedate',
    value: expDate
});
If you are still facing issues, make sure you have imported the
N/format
module into your script. You can do this by adding
['N/format']
to your define function at the top of your script. ****** 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.827071488
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819699585
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818825126
Please provide your feedback on this answer.