I would like to have it that when a row is edited that it only copies the name, phone and adds a timestamp of the edit on another tab in Google Sheets. Each row on Update sheet should be a new row from edit.
function onEdit(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Main');
var date = new Date();
var rowIdx = sheet.getActiveRange().getRowIndex();
var rowValues = sheet.getRange(rowIdx,1,1,sheet.getLastRow()).getValues();
Logger.log(rowValues);
var destValues = [];
destValues.push(rowValues[0][0]);// copy data from col A to col A
destValues.push(rowValues[0][2]);// copy data from col C to col B
destValues.push(rowValues[0][1]);// copy data from col B to col C
destValues.push(rowValues[0][3]);// copy data from col D to col D
var dest = SpreadsheetApp.getActive().getSheetByName('Updates');
dest.getRange(dest.getLastRow()+1,1,1,destValues.length).setValues([destValues]);
}
The above is working but i cannot figure out how to get the timestamp to show.
The outcome should display the roadname, phone and then C:C should have timestamp of change made.
I have updated the below sheet to show expected outcome
Expected outcome of 2nd Tab
Roadname | Phone | Timestamp |
---|---|---|
Edit 1 | 555-5555 | 2/16/2023 09:14:52 |
edit 2 | 555-5555 | 2/16/2023 09:14:52 |
Edit 3 | 555-5555 | 2/16/2023 09:14:52 |
Edit 4 | 555-5555 | 2/16/2023 09:14:52 |
Data Table:
Road Name | Date Contacted | Phone number | Clan Name | State | Status | Comment |
---|---|---|---|---|---|---|
Name2 | 2/1/23 | 5551212222 | Some Comment 1 | |||
Name1 | 2/1/23 | 5551212222 | Some comment 2 | |||
Name4 | 2/1/23 | 5551212222 | Called him |