In the following code it tells me inside the function that the local variables are not defined, when it worked before.
I'm looking to be able to debug the code so that it works again, when a trigger is activated.
function changeSheet(e) {
if (e.changeType == "INSERT_GRID") {
// list your sheet names in here:
var sheetNames = ["Principal", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Lunes_blanco", "Martes_blanco", "Miércoles_blanco", "Jueves_blanco", "Viernes_blanco", "DATOS", "Automata"];
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
if (sheets.length != sheetNames.length) {
for (var i = 0; i < sheets.length; i++) {
if (sheetNames.includes(sheets[i].getName())) {
continue;
}
else {
SpreadsheetApp.getActiveSpreadsheet().deleteSheet(sheets[i])
}
}
}
}
During debugging the following message appears:
changeSheet @ debugged-code 22
Variables
Local
e: undefined
sheetNames: undefinded
sheets: undefined
i: undefined