最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google sheets - How do I resolve error script Exceeded maximum execution time (copy Rows)? - Stack Overflow

programmeradmin3浏览0评论

Overview:

I'm attempting to Copy a list of records from one sheet tab to another, in this case the Index tab to the All Work Orders tab. The data set contains 44 columns, and on average approximately 200 - 300 rows. The Goal of the apps script function provided, is to copy the list of rows from the origin (Index) tab, to destination (All Work Orders) tab.

Current issue:

When the function is run/executed, it starts copying the list of records but after a few minutes, I keep receiving the following error message: (exceeded maximum execution time) and the function/copy process stops mid execution. How can I resolve this error?

Further guidance is much appreciated. Thanks

function copyDatabase_25() {

   var ui = SpreadsheetApp.getUi();

var response=ui.alert("Complete", "Are you sure?", ui.ButtonSet.YES_NO);

//checking the user response

            if(response==ui.Button.NO)
            {
            return; //exit from this function
            }

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Index");
  var desinationsheet = ss.getSheetByName("All Work Orders");

  var startRow = 2; 
  var numRows = sheet.getLastRow() - startRow + 1; 
  var startCol = 24;
  var numCols = 44;
  var startColTarget = 1;
  var dataRange = sheet.getRange(startRow, startCol, numRows, numCols); 
  var data = dataRange.getValues(); 
  var Copy = "Copy"; 
  var firstEmptyRow = sheet.getRange("A2:AQ").getNextDataCell(SpreadsheetApp.Direction.DOWN).getRow() + 1;
  var dataToCopy = data.filter(row => row[2] !== Copy);

  desinationsheet.getRange(firstEmptyRow, startColTarget, dataToCopy.length, dataToCopy[0].length).setValues(dataToCopy);

      ss.toast("Completed successfully")


}
发布评论

评论列表(0)

  1. 暂无评论