// Apps Script: auto timestamp on status change + autosort const SHEET_ID = "12pL2cVoH5GWqbWk-1BMWuwunSbOpdUpm7PHMBYV59jY"; const SHEET_TAB_NAME = "Sheet1"; // change if your tab name is different function onEdit(e){ try{ const ss = SpreadsheetApp.openById(SHEET_ID); const sh = ss.getSheetByName(SHEET_TAB_NAME); if(!sh) return; const range = e.range; const row = range.getRow(); const col = range.getColumn(); if(row <= 1) return; // header // Status column = I -> column 9 (adjust if different) const STATUS_COL = 9; const TIMESTAMP_COL = 12; // column L // When status changed, write timestamp if(col === STATUS_COL){ sh.getRange(row, TIMESTAMP_COL).setValue(new Date()); } // Auto-sort by Date (col B=2) then Time (col C=3) const lastRow = sh.getLastRow(); if(lastRow > 2){ sh.getRange(2,1,lastRow-1,sh.getLastColumn()).sort([{column:2, ascending:true},{column:3, ascending:true}]); } }catch(err){ Logger.log("Error in onEdit: "+err); } }