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,