0

Simple code is failing with error (after displaying 3 in logger) in the first iteration itself.

Exception: Service Spreadsheets timed out while accessing document with id .....

This was reported in issuetracker 3 years back and it is marked "Fixed" The error is still there and the function failing 25 times a day (hourly timer)

https://issuetracker.google.com/issues/148894990

function lockrow(){ 
  // timer to run every hour
  var ss = SpreadsheetApp.getActiveSpreadsheet();  
  var gpsht = ss.getSheetByName("GatePass");  
  var gplr=gpsht.getLastRow();
  var locks = gpsht.getRange("W:X").getValues();
  for (i=gplr-1 ; i > 1 ; i--){//
    if (locks[i][1]==1) { //printed
      if (locks[i][0]=="") { //not locked
        Logger.log("Locking row - " + (i+1));
        var range = gpsht.getRange('A'+(i+1)+':Q'+(i+1)).activate();
        Logger.log(2)
        var protection = range.protect().setDescription('Locked');
        Logger.log(3)
        protection.removeEditors(protection.getEditors());
        Logger.log(4)
        Logger.log("Success")
        gpsht.getRange("W"+(i+1)).setValue(1);
        Logger.log(5)
        SpreadsheetApp.flush();
        Utilities.sleep(3000) ;
      }
     }//if
  }//for
}//function
````
arul selvan
  • 616
  • 4
  • 17
  • Does this answer your question? [Google Sheet Error: Service Spreadsheets timed out while accessing document with id](https://stackoverflow.com/questions/64535334/google-sheet-error-service-spreadsheets-timed-out-while-accessing-document-with) – Giselle Valladares Feb 15 '23 at 14:29
  • I am part of that question. My problem still remains – arul selvan Feb 16 '23 at 06:12

0 Answers0