Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Apps Script - how to get the deleted row in onEdit script, or onDelete?

I need to get the row number and the content for the deleted row in onEdit trigger script. or is there an onDelete function?

Basically, when user deletes one row or a range of rows, the script should be notified the range deleted, in some way.

like image 770
Michael SM Avatar asked Oct 25 '25 23:10

Michael SM


2 Answers

If user deletes one cell this works:

function onEdit(e) {
    if (e.value==e.source.getActiveSheet().getActiveCell().getValue()) {
        //Things to do for normal edition
    } else {
        //Things to do if cell was deleted
        deleted_range = e.range
    }
}

I'm not shure if that's the right solution but works fine until now. For multiple cells i can't find a solution yet :/

like image 147
Marco Avatar answered Oct 28 '25 12:10

Marco


This is not possible. There's a feature request opened regarding this, you may want to star it to keep track of updates and kind of vote for it.

Issue 1363: Add trigger for spreadsheet column or row operations

like image 27
Henrique G. Abreu Avatar answered Oct 28 '25 12:10

Henrique G. Abreu