I'm trying to move an entire row to another sheet based on a specific value. See code below:
function onEdit(e) {
const src = e.source.getActiveSheet();
const r = e.range;
if (src.getName() == "Sheet1" && r.columnStart == 4 && r.getValue() == "TRUE") {
const dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
src.getRange(r.rowStart,1,1,19).moveTo(dest.getRange(dest.getLastRow()+1,1,1,19));
src.deleteRow(r.rowStart);
}
}
The function works when I delete the getValue part, since the script then basically runs on the fact that something is edited. But I'd like it to only work if the value is TRUE, hence the getValue.
Any idea why this is not working?