2

I'm trying to detect updates from Google Sheets. I am following the Sheets API V3 documentation and have successfully been able to watch a sheet and get updates from it.

However I'm not getting every update. For example if I make a change in the sheet I will receive an update from Google. If I make a second change within say a minute I may or may not get an update. A third change will never be sent through. If I then refresh the sheet I get an update immediately.

I've done extensive testing and am under the impression that Google isn't sending the updates I'm not getting. Is there some kind of throttling done by Google or is this a bug in the API?

UPDATE: I'll provide some more context to make it clearer on exactly what I mean.

I'm trying to get the actual data that was changed in a Google Sheet. Using this screenshot as an example, whenever a value is changed in the sheet I want Google to push the updates to me in real-time. I'm using the Google Sheets API to watch the sheet (drive.files.watch), creating the watch works fine so that's not the issue. The issue is that I only get the update pushes sometimes e.g the first two changes made will get sent to me. But if there's a large number of edits made they never get sent.

  • I'm running into this exact same issue and assumed I had to be doing something wrong, but apparently it's not an isolated incident. Any progress on this on your end? – Jakob May 20 '17 at 20:19

1 Answers1

0

Try to set the notification rules in your spreadsheet manually. You can do this by going to the Tools -> Notification Rules, click the radio button "Any changes are made" and "Email - right away" to receive the notification right away when something changed in your spreadsheet.

Another way to received notification is to create a function that checks for the changes. Check the sample code in this SO question for that.

var sheet = **whatever**;//The spreadsheet where you will be making changes
var range = **whatever**;//The range that you will be checking for changes
var compSheet = **whatever**;//The sheet that you will compare with for changes
function checkMatch(){
  var myCurrent = sheet.getRange(range).getValues();
  var myComparison = compSheet.getRange(range).getvalues();
  if(myCurrent == myComparison){//Checks to see if there are any differences
    for(i=0;i<compSheet.length;++i){ //Since getValues returns a 'multi-dimensional' array, 2 for loops are used to compare each element
     for(j=0;j<compSheet[i].length;++i){
      if(myCurrent[i][j] != myComparison[i][j]){//Determines if there is a difference;
       //***Whatever you want to do with the differences, put them here***
     }
    }

    myEmailer(sheet.getUrl());//Passes the url of sheet to youur emailer function 
    compSheet.getRange(range).setValues(myCurrent);//Updates compSheet so that next time is can check for the next series of changes
    }
  }

Hope it helps you.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • Thanks for your suggestions but they aren't quite what I'm looking for here. I've updated to question to make it easier to understand what I mean. – James Petty Jan 11 '17 at 22:52