OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Script to move row to new sheet started to timeout

  • Thread starter Thread starter Shawn W
  • Start date Start date

Shawn W

I use a third-party form to add entries to a Google Sheet tab titled "Inbox." I added a script on a time-based trigger to...

  1. Check if column J contains "Y"
  2. If yes, move the row to a new sheet titled "Completed"
  3. Delete the row from "Inbox"
  4. Add a new blank row to "Inbox"

Everything was working fine, but recently started receiving timeout errors. This usually occurs when the Inbox starts to fill up with entries. I'm attaching a copy of the GS.



function doneCopy() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Inbox");
  var values = sheet.getRange(1, 10, sheet.getLastRow(), 1).getValues();
  var moveRows = values.reduce(function(ar, e, i) {
    if (e[0] == "Y") ar.push(i + 1);
    return ar;
  }, []);
  var targetSheet = ss.getSheetByName("Completed");
  moveRows.forEach(function(e) {
    sheet.getRange(e, 1, 1, sheet.getLastColumn()).copyTo(targetSheet.getRange(targetSheet.getLastRow() + 1, 1),{contentsOnly:true});
      sheet.insertRowsAfter(sheet.getMaxRows(), 1);

  moveRows.reverse().forEach(function(e) {sheet.deleteRow(e)});


I'm wondering if there is something in my script that is slowing the run down. I'm hoping someone might have a suggestion or solution. Thank you.

Continue reading...

Latest posts