Prefacing this with the fact that I'm not especially versed in Google Sheet scripting, just fairly decent at Googling and making stuff work for me.
I'm using IFTTT.com to automatically append a Google Sheet if I save an article in my RSS reader.
With how IFTTT works, it adds a row to the bottom of a sheet based on various attributes of the article saved.
I'm getting hung up on adding an automatic non-volatile timestamp to the row.
I've tried using the automatic timestamping function below, which works when I type into a cell, but not when the sheet is appended.
function onEdit(event)
{
var timezone = "GMT-5";
var timestamp_format = "MM-dd-yyyy"; // Timestamp Format.
var updateColName = "Article Title";
var timeStampColName = "Date Discovered";
var sheet = event.source.getSheetByName('Sheet1'); //Name of the sheet where you want to run this script.
var actRng = event.source.getActiveRange();
var editColumn = actRng.getColumn();
var index = actRng.getRowIndex();
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
var dateCol = headers[0].indexOf(timeStampColName);
var updateCol = headers[0].indexOf(updateColName); updateCol = updateCol+1;
if (dateCol > -1 && index > 1 && editColumn == updateCol) { // only timestamp if 'Last Updated' header exists, but not in the header row itself!
var cell = sheet.getRange(index, dateCol + 1);
var date = Utilities.formatDate(new Date(), timezone, timestamp_format);
cell.setValue(date);
}
}
IFTTT lets you set what data gets ported into what column, and has specific "ingredients" for data from Feedly you can put into a column.
They also allow for static text, and formulas.
Realizing this, I found the following custom function, which seems to somewhat work.
function timestamp() {
return new Date()
}
This allowed me to add a function to check whether the title of the article had content, and timestamp if true.
=Timestamp(INDIRECT("E"&ROW()))
Oddly, the first row with this formula did not change when I reloaded the sheet today (I entered the formula yesterday), nor did a row further down the sheet.
Source sheet: https://docs.google.com/spreadsheets/d/1ybfgOgBkqHdld9_sexzMfdMV2lT6Qp7WgQ8Di96S-a8/edit?usp=sharing
Many thanks ahead of time.