Goal: Insert the current date or tomorrow's date to a cell under Column K/Row of user edit, depending on when the user changes a cell under Column D to "Chat => Email." And if possible, I want the comparison and output of the date to be based on the JST (Japan Standard Time) time zone.
Context of my code: In my below code, I've created a function called "insertDeadlineDate()" which receives onEdit() information from another .gs file. Within the insertDeadlineDate() code, I'm trying to create an if statement to check the following points and execute the result.
- If the user changed the cell value to "Chat => Email" AND if the current time is between 9:30 A.M. and 2:00 P.M. (JST), then insert the current day's date to Column K/Row of user edit.
- If the user changed the cell value to "Chat => Email" AND if the current time is between 2:00 P.M. and 6:30 P.M. (JST), then insert the current day's date to Column K/Row of user edit.
FYI: I have the IF statements blank because I don't know what to write. I'm sorry...
function insertDeadlineDate(range, sheetName, row, column) {
const statusSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Status');
const editedRangeValue = range.getValue();
// Column numbers for Status sheet
const caseTypeColumnStatus = 4;
if (sheetName == 'Status' && column == ticketTypeColumnStatus && row > 15 && editedRangeValue == 'Chat => Email') {
var statusColumn = column + 3;
if () { // If the current time is between 9:30 A.M. and 2:00 P.M. (JST), then TRUE.
// Insert today's date
statusSheet.getRange(row, statusColumn).setValue(new Date());
} else if () { // If the current time is between 2:00 P.M. and 6:30 P.M. (JST), then TRUE.
// Insert tomorrow's date
statusSheet.getRange(row, statusColumn).setValue();
}
}
}
