In Google Sheets, I am trying to delete an entire row when one cell in that row contains the phrase \"Delivered.\" The onEdit function won\'t work for my needs because it re
Try this:
function createTimeBasedTriggerIfYouDontAlreadyHaveOne() {
if(!isTrigger(deleteDeliveredRows)) {
ScriptApp.newTrigger(deleteDeliveredRows).timeBased().everyDays(1).atHour(0).create();
}
}
function deleteDeliveredRows() {
var ss=SpreadsheetApp.openById('ssid')
var sh=ss.getSheetByName('sheetname');
var rowStart=2;//assume 1 row for headers
var rg=sh.getRange(rowStart,1,sh.getLastRow()-rowStart+1,sh.getLastColumn());
var vA=rg.getValues();
var d=0;
for(var i=0;i<vA.length;i++) {
if(vA[i][8]=="Delivered") {
sh.deleteRow(i + rowStart - d++);
}
}
}
function isTrigger(funcName){
var r=false;
if(funcName){
var allTriggers=ScriptApp.getProjectTriggers();
for(var i=0;i<allTriggers.length;i++){
if(funcName==allTriggers[i].getHandlerFunction()){
r=true;
break;
}
}
}
return r;
}