The n/format module helps to parse formatted data into strings and to convert strings into a specified format. A string can be formatted to a raw Date object, and then parses it back to the formatted string.
The following code snippet demonstrates the above:
let initialDate = “07/31/2024”;
let parsedDate = format.parse(
{
value: initialDate,
type: format.Type.DATE
});
let formattedDate = format.format(
{
value: parsedDateStringAsRawDateObject,
type: format.Type.DATE
});
This can be used in conditions where we need to format data according to personal preferences set in the NetSuite account.
The error shows {“type”:”error.SuiteScriptError”,”name”:”INVALID_FLD_VALUE”,”message”:”Invalid date value (must be MM/DD/YYYY)”}