javascript google script appendRow服务错误失败

时间:2018-04-20 18:10:07

标签: javascript google-apps-script

我有一个已运行3个月且几周前开始的Google Apps脚本我收到的服务错误"关于我在下面加粗的Appendrow功能。关于如何解决这个问题的任何想法?

function updateACOPS2(){
  var ss = SpreadsheetApp.openById(".....") 
  var sheetSubmission = ss.getSheetByName("Sheet8");
  var dataSubmission = sheetSubmission.getDataRange().getValues();
  var lastColSubmission = sheetSubmission.getLastColumn();
  var ssActive = SpreadsheetApp.openById("....")
  var sheetActive = ssActive.getSheetByName("AcopsAll");
  var sheetMain = ssActive.getSheetByName("Sheet1");
  var dataActive = sheetActive.getDataRange().getValues();
  var lastrow = sheetActive.getLastRow(); 

  for(var i = 1; i < dataSubmission.length && dataSubmission[i][2] != ""; i++){

    var currentIDSubmission = dataSubmission[i][2] + dataSubmission[i][3];
    var checkGotMatch = false;
    var toCopyRow = sheetSubmission.getRange(i+1,1,1,71);   
// copy entire row for new record
    Logger.log(currentIDSubmission);

  // if there is a matching record flag as matched

    for(var j = 1; j<dataActive.length; j++){

      var currentIDActive = dataActive[j][2] + dataActive[j][3];
      var currentIDSub = dataSubmission[i][2];

      if(currentIDSub != '' && currentIDSubmission == currentIDActive){  

        checkGotMatch = true;
        Logger.log(currentIDActive);

        break;

      }

    }

    // if it is a new record Append entire row

    if(currentIDSub != '' && checkGotMatch == false){

      **sheetMain.appendRow(toCopyRow.getValues()[0]);**

    }      
  }
  SpreadsheetApp.flush();
  ss.toast("ACOPS Active has been updated.", "Complete");
}

1 个答案:

答案 0 :(得分:-1)

在appendRow中你需要传递一个数组,所以更新你的appendRow并尝试

sheetMain.appendRow([toCopyRow.getValues()[0]])