I have this code that will move an entire row of data from one sheet to another within the same workbook based on Checkbox value:
function onEdit(e){
// WORKING
const src = e.source.getActiveSheet();
const r = e.range;
if (r.rowStart == 1 || r.columnStart != 3) return;
let dest;
if (src.getName() == "New")
dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Complete");
else if (src.getName() == "Complete")
dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("New");
src.getRange(r.rowStart,1,1,3).moveTo(dest.getRange(dest.getLastRow()+1,1,1,3));
src.deleteRow(r.rowStart);
// NOT WORKING
src.getRange("A2:Z").sort([{column: 2, ascending: true}]);
dest.getRange("A2:Z").sort([{column: 2, ascending: true}]);
}
In addition, after the moving has taken place, I am trying to get both the sheets to "re-sort". I have tried with a filer on the current column, but I than have to manually re-filter after the moving. "Not working" = no sorting is taking place after the rows are moved!
How can both sheets be re-sorted after the rows has been triggered to move?