1

I'm using the below script to capture the entry_timestamp of every new row that gets imported from a different Google Spreadsheet using the 'IMPORTRANGE' function.

function onEdit(e) {

    var ss = e.source.getActiveSheet();
    if (ss.getName() !== 'Raw Data' || e.range.columnStart !== 3) return;
    e.range.offset(0, -2)
        .setValue(e.value ? new Date() : null);
}

While the above snippet works like charm every time I "edit" something in col.C, I would like the same functionality whenever a new line item gets inserted because of changes in the other spreadsheet which I'm reading using the IMPORTRANGE function.

Can any expert help me with that? I have created a sample sheet for your reference here

Any help is much appreciated :)

Rubén
  • 34,714
  • 9
  • 70
  • 166
Karthik
  • 7
  • 3
  • Possible duplicate of [Trigger a script when a formula changes a cell value](https://stackoverflow.com/questions/42815059/trigger-a-script-when-a-formula-changes-a-cell-value) – Rubén Nov 24 '18 at 01:28

1 Answers1

0

I just ran into this issue, and found a solution. Make a function called onChange, and set it up as a trigger to be fired on change for your spreadsheet. This routine will fire when Importrange makes a change.

Edit: Sorry, it doesn't look like this is going to work because the event object for onChange doesn't give the information needed.

Bradley
  • 81
  • 1
  • 3