This Script Error and me are about to fight: {"ty...
# general
j
This Script Error and me are about to fight: {"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"Invalid date value (must be M/D/YYYY) I've tried:
var formattedDate = format.format({
value: previousSunday,
type: format.Type.DATE
});
customRecord.setValue({
fieldId: 'custrecord_nr_ttl_week',
value: previousSunday
});
and
var formattedDate = (previousSunday.getMonth() + 1) + '/' + previousSunday.getDate() + '/' + previousSunday.getFullYear();
a
var formattedDate = (previousSunday.getMonth() + 1) + '/' + previousSunday.getDate() + '/' + previousSunday.getFullYear(); After this, add this line: formattedDate = new Date(formattedDate)
j
Alright let me give this a shot, NetSuite is being a fickle mistress right now
nope still hates us {"type":"error.SuiteScriptError","name":"INVALID_DATE_VALUE_1_MUST_MATCH_2","message":"Invalid date value Sun Aug 18 000000 PDT 2024 (must match M/d/yy)
// Manually format the date as M/D/YYYY
var formattedDate = (previousSunday.getMonth() + 1) + '/' + previousSunday.getDate() + '/' + previousSunday.getFullYear();
// Convert the formatted date string back to a Date object
formattedDate = new Date(formattedDate);
@ASH I got it, whew
a
How😆
j
Copy code
// Get the previous Sunday date
var today = new Date();
var dayOfWeek = today.getDay();
var previousSunday = new Date(today.setDate(today.getDate() - dayOfWeek));

// Strip time from the date
previousSunday.setHours(0, 0, 0, 0);
image.png
a
Congrats .. and thanks for sharing the solution. Might help me in future.🙏
j
Don't thank me, thank ChatGPT lmao
🤣 2
Now I just need to get this other script working for field calculations
Now I have a client script I can't even get to trigger and show any logs