The big picture problem is I am adding a date to cell one week from today when an adjacent cell is edited. So far so good. However, it needs to not change when the irl date changes, or if the adjacent cell is edited a second time.
Basically been trying to check and see if there is already a date in the cell, and if so, simply returning. But it isn't doing the string comparison properly for some reason. It never recognizes it as an empty string. Then I try to use includes(), it tells me that includes() cannot be used on an object. My understanding is getDisplayValue() should always return a string? A bit at a loss.
function getDate(progress) {
//progress: cell showing progress state (Not started, begun, completed)
var range = SpreadsheetApp.getActiveRange();
var d = range.getDisplayValue();
if(progress == 'Completed') { return 'done'; }
if(d != '') { return; } //if due date cell already has a date, don't change it
today = new Date();
due = new Date();
due.setDate(today.getDate() + 7); //one week from today
return due;
}
Any idea what the issue is with this code? Or open to another solution if there is something more elegant.
Logger.log({d:d,type:typeOf d})