I have a script bound to my Google spreadsheet with a simple onEdit(e) trigger that isn't working.
The script is supposed to move the edited row to Closed Cases, then delete the original row, if the following conditions in the active sheet are all true:
- The active sheet is named
11th Grade - The edited cell is in the checkbox Column 14 / N
- The checkbox is selected /
true - Column 4 / D contains the value
"Success"
When I make changes to 11th Grade the script always completes successfully but the row is never moved or deleted.
function onEdit(e) { var ss = e.source; var activatedSheetName = ss.getActiveSheet().getName(); var activatedCell = ss.getActiveSelection(); var activatedCellRow = activatedCell.getRow(); var activatedCellColumn = activatedCell.getColumn(); var activatedCellValue = activatedCell.getValue(); var input = ss.getSheetByName("11th Grade"); // source sheet var closed = ss.getSheetByName("Closed Cases"); // target sheet // if the value in column D is "Success", move the row to target sheet if (activatedSheetName == input.getName() && activatedCellColumn == 14 && activatedCellValue == "True") { // insert a new row at the second row of the target sheet closedlosed.insertRows(2,1); // move the entire source row to the second row of target sheet var rangeToMove = input.getRange(/*startRow*/ activatedCellRow, /*startColumn*/ 1, /*numRows*/ 1, /*numColumns*/ input.getMaxColumns()); rangeToMove.moveTo(closedlosed.getRange("A2")); // delete row from source sheet input.deleteRows(activatedCellRow,1); }}