I am trying to trigger a Google App Script that I have bound to a google sheet.
Data from firebase is pulled into a sheet which should trigger the script. I'm currently using onEdit(e) which works when I manually add the data in but doesn't work when the data is updated from firebase. Is there any way I can set up a trigger to run the function every time the cell values in a specific range are changed.
Thanks!
Script
function onEdit(e) {
var ss = SpreadsheetApp.getActive()
var dumpingGround = ss.getSheetByName("Dumping Ground")
var dataDump = ss.getSheetByName("Data Dump")
var ddLastRow = dataDump.getLastRow() + 1
var editCol = e.range.getColumn();
var editRow = e.range.getRow();
Logger.log("edit")
/*Copy from dumping ground to data dump*/
if ((editRow == 1 && editCol == 2) || (editRow == 1 && editCol == 3)){
/*Set required range for data dump and dumping ground*/
var ddRange = '\'Data Dump\'!A' +ddLastRow+ ':BF' + ddLastRow
var dgCopyRange = '\'Dumping Ground\'!B1:BF1'
/*Copy action*/
ss.getRange('\'Dumping Ground\'!B1:BF1').copyTo(ss.getRange(ddRange), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
/*Check data dump row count and delete 1000 rows if necessary*/
if(ddLastRow = 9999){
dataDump.deleteRows(1, 1000);
}
}
};
onChange()
is triggered. – TheMaster