IFTTT and Google Sheets: onChange trigger e.changeType returns 'EDIT' instead of 'INSERT_ROW' on insert

259 views Asked by At

IFTTT App uses: Google Assistant Google Sheet IFTTT app 'Add row to spreadsheet'

What has broken in the last two weeks is the value in the sheet of e.changeType is now always 'EDIT' instead of 'INSERT_ROW'. I need the value of e.changeType to be 'INSERT_ROW' because if I happen to hand-edit the sheet I don't want my Sheet trigger function to fire.

Everything worked correctly starting January of 2020 and began to fail in the 2nd week of November 2020. I've successfully added hundreds of rows to the Google Sheet using this methodology. No problems at all until just recently.

Also, I have made no code changes to the Script in the Google Sheet and there have been no changes in the IFTTT app.

Code sample for my Google Sheet script:

function myOnChange(e) {
  if (e.changeType == 'INSERT_ROW')
  {
    var mySheet = SpreadsheetApp.getActiveSheet();
    var lastrow = SpreadsheetApp.getActiveSheet().getLastRow();
    mySheet.getRange(lastrow, 3).setValue(new Date());    
    mySheet.getRange(lastrow,4).setValue(uuidv4());
  }
 }

I've confirmed that the problem is not in Google Sheets as I am successfully able to insert a row via a Python app and the trigger fires and the value of e.changeType is 'INSERT_ROW' which is what I expect.

I have also verified that my myOnChange function runs correctly when I directly insert a row while in my Google Sheet and the value of e.changeType is correct as 'INSERT_ROW'.

Now, it's broken and I think that it's in the way IFTTT inserts the row into the Google Sheet.

I posted a bug with the Google Sheet team, but after I successfully inserted rows via Python and it is apparent that the problem is within IFTTT, the Google team is off the hook and cannot fix the problem.

I'll post this on whatever support board that IFTTT has.

Has anyone else seen this?

1

There are 1 answers

0
Jeff L On

This problem has been mysteriously fixed by either Google or IFTTT. All of a sudden the e.changeType in the Google Sheet has the value of 'INSERT_ROW' and my macros now are running correctly.