0
votes

It would seems I am stuck with a consistant "Server Encountered an Error" when I am trying in my function to use the insertRows() call or insertRowsAfter() and then do a getRange() operation call within the range of cells newly created (like changing the font weight, or setvalues in the new cells).

When I call my function I always get a google "Server Encountered and Error". When I call my function in debug mode, step by step: no errors!!! I have no error logs showing when doing a catch.

I tried a Spreadsheet.flush() call before the getRange() operation, not helping.

  function test() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sdebtcal = ss.getSheetByName('Debt');  
    var max_rows = sdebtcal.getMaxRows(); // sheet set with only 5 rows to test
    sdebtcal.insertRowsAfter( max_rows , 20); // adding 20 rows 
    sdebtcal.getRange(max_rows+5, 1, 2, 1).setFontWeight('bold'); // trying to setFontWeight in the new range of cells
  }

I have to say I tried a with a blank spreadsheet, and I do not have the problem. Only with my current large spreadsheet. Though the test sheet is a small one (2 rows to test!). Also I am not reaching any max cells limits on the spreadsheet.

Anybody with a hint? Possible bug from the spreadsheet script API with large spreadsheets?

Regards,

1

1 Answers

0
votes

I discovered that problems I experienced with InsertRowsBefore() and InsertRowsAfter() disappeared if the spreadsheet wasn't open on the client side at the time the script executes. So if it's possible for you to insert the rows either from a script in a different spreadsheet or on a timed trigger, then you might find you can work around the problem. Good luck!

Here's a link to a post I made about it on the GAS forum if you want more detail and you might be interested in adding a comment to Issue 1270 about it too.