I'm using two scripts to achieve my goal. The first script inserts a timestamp in the adjacent column when an update is made to a field. This works great. The next script monitors the timestamp column and when the timestamp changes, copy entire row to a "recent updates" sheet. I'm then going to use the Awesome Table plugin to create a news feed for all the recent updates.
When the timestamp column is blank and an edit is made the timestamp is appropriately entered into the timestamp column. The second script picks it up and crops it into my "recent updates" sheet...
...but if a previous update was made and the timestamp field is already present the script runs without error, but does not copy the new row to "recent updates". How can I get the row to paste every time the timestamp field changes?
/**
* @file Copy row to new cell when date value changes
* {@link https://support.google.com/docs/thread/13191603}
*/
/**
* Runs the snippet.
* Please, register this function for EDIT event
* once from the owner of the Spreadsheet
*
* @param {GoogleAppsScript.Events.SheetsOnEdit} e
*/
function CopyUpdates(e) {
if (!e) return;
var currentSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var currentRange = currentSheet.getActiveRange();
var currentRow = currentRange.getRow();
if (
e.value &&
currentSheet.getName() == "Open Actions - Cutover Punchlist" , "Open Actions - FSA Interfaces" , "Open Actions - General" &&
currentRow > 2 &&
currentRange.getColumn() == 9
) {
var dataRange = currentSheet.getRange(currentRow + ':' + currentRow);
var destinationSheet = currentSheet.getParent().getSheetByName("RecentUpdates");
var destinationRow = destinationSheet.getLastRow() + 1;
dataRange.copyTo(destinationSheet.getRange(destinationRow, 1), {
contentsOnly: true
});
}
}