2

我在工作表上设置了一个触发器,该触发器设置为在提交关联表单时运行。奇怪的是,这似乎曾经奏效过一次,但在所有其他时间我都通过电子邮件收到了这个失败摘要:

太多同时调用:电子表格(第 20 行,文件“代码”)

有问题的行是:

var rData = sh.getRange(row, 1, 1, 3).getValues();

在上下文中,这就是我正在做的事情:

 function addSheet() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();
  var row = sh.getActiveRange().getRowIndex();
  var rData = sh.getRange(row, 1, 1, 3).getValues();

  if (row == 1) {
    ss.toast("The are the column titles, you can not send these.");    
    return
  }

  if(rData[0][0] != null || rData[0][1] != null || rData[0][2] != null) {
    try {      

      //set active spreadsheet to template
      var ss = SpreadsheetApp.openById("TEMPLATESHEETKEY");

      // Create new sheet with a copy of template and name it with the row number, space, and event name
      var newSS = ss.copy(+(row)+' '+rData[0][1]);


      // Move to original folder
      var targetFolder = DriveApp.getFolderById("MYFOLDERKEY");
      var newSSFile = DriveApp.getFileById(newSS.getId());
      targetFolder.addFile(newSSFile);
      DriveApp.getRootFolder().removeFile(newSSFile);     



      //target title space and set it as the name/first cell
      newSS.getRange("D8").setValue('=importrange("MYSHEETKEY","eventlist!B'+(row)+'")');


      //target date space and set it as the date
      newSS.getRange("D11").setValue('=importrange("MYSHEETKEY","eventlist!C'+(row)+'")');



    } catch(e) {
      throw 'Something has gone wrong...';      
    }
    }
    }

提前感谢您的任何建议...

更新 - 虽然我没有改变任何东西,但这开始持续工作了一段时间。我想知道这是否与配额限制有关?从那以后它又停止工作了!

4

0 回答 0