onEdit along with IMPORTRANGE?

777 views Asked by At

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 :)

1

There are 1 answers

0
Bradley On

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.