我跳进一个已经工作了一年多的脚本 - 现在已经开始发布TypeError:无法调用方法" getDay"未定义的。
我认为这是导致问题的功能 - 但不确定如何解决:
function businessDaysBetween(startDate, endDate) {
var dayDiff = endDate.getDay() - startDate.getDay();
if (dayDiff < 0) {
dayDiff = 5 + dayDiff;
}
return Math.floor((((endDate.getTime() - startDate.getTime())/1000/60/60/24/7) * 5) + dayDiff);
}
function sendReminderEmail() {
try {
//Open Google spreadsheet "New Hire - Notification", and retrieve "New Hire" sheet
var spreadsheet = SpreadsheetApp.openById("is identified");
var sheet = spreadsheet.getSheetByName("New Hire");
}
catch (e)
{
Browser.msgBox(e.message);
}
var rows = sheet.getLastRow();
var currentDate = new Date();
//Iterate through rows
for (var i = 2; i <= rows; i++) {
var hrngMgrComplete = sheet.getRange(i, sheet.getLastColumn());
//Check if hiring manager has completed details form
if (hrngMgrComplete.getValue() != "Yes") {
var reminderDate = sheet.getRange(i, 13).getValue();
var days = businessDaysBetween(reminderDate, currentDate);
//check if last reminder was sent earlier than 3 business days or more
//from today.
if (days >= 3) {
var noOfReminders = sheet.getRange(i, 14).getValue();
//Send appropriate email based on how many reminders have been received
if (noOfReminders == 0) {
sendFirstReminder(i);
}
else if (noOfReminders == 1) {
sendSecondReminder(i);
}
else if (noOfReminders == 2) {
sendHRNotification(i);
}
}
}
}
}
可能是 var currentDate = new Date();