I'm teaching myself app-script, and created a simple function to delete a row if there was an error. Here is the code:
//GLOBALS
var SS = SpreadsheetApp.openById("the_sheet_ID"); //just a placeholder because I didn't want to post the real ID
var SHEET = SS.getSheetByName("300x250");
var RANGE = SHEET.getDataRange();
var DELETE_VAL = "#N/A";
var COL_TO_SEARCH = 2; // The column to search for the DELETE_VAL (Zero is first)
function deleteEachRow(){
var rangeVals = RANGE.getValues();
//Reverse the 'for' loop.
for(var i = rangeVals.length-1; i >= 0; i--){
if(rangeVals[i][COL_TO_SEARCH] === DELETE_VAL){
SHEET.deleteRow(i+1);
};
};
};
I have been receiving e-mails from app script telling me a server error occurred. Below is a copy of the e-mail:
Your script, Deleting_Rows, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.
4/16/20 1:27 AM deleteEachRow We're sorry, a server error occurred. Please wait a bit and try again. time-based 4/16/20 1:27 AM
Sincerely,
Google Apps Script
The function is timed to run every minute, so it usually fixes itself. I've seen this issue for triggers from deleted functions, or for the broken click here link, but my function is not deleted, and the link works. I haven't been able to find any information about what is causing the error, how to fix it, if the error has to do with my code or google's servers. Any information or insight anyone has would be super helpful!