为什么这个脚本可以从我原来的googlesheet中工作,但不能从工作表的副本中工作

时间:2017-06-05 15:50:34

标签: google-apps-script

当我从工作表的副本运行此脚本(与原始工作表中的脚本相同)时,我发现"发生服务器错误"。我无法找到调试可能导致问题的方法。任何帮助都会很棒。谢谢。吉姆

function checkReminder() {
// get the spreadsheet object
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// set the first sheet as active
SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[0]);
// fetch this sheet
var sheet = spreadsheet.getActiveSheet();

// figure out what the last row is
var lastRow = sheet.getLastRow();

// start with row 114
var startRow = 114;

// grab column 3 (the numbers in service column) 
var range = sheet.getRange(114,3,lastRow-startRow+1,1 );
var numRows = range.getNumRows();
var number_of_items_values = range.getValues();

// Now, grab the reminder name column
range = sheet.getRange(114, 1, lastRow-startRow+1, 1);
var reminder_info_values = range.getValues();

var warning_count = 0;
var msg = "";

// Loop over the days left values
for (var i = 0; i <= numRows - 1; i++) {
var number_items = number_of_items_values[i][0];
if(number_items > 0) {
  // if it's exactly 7, do something with the data.
  var reminder_name = reminder_info_values[i][0];

  msg = msg+number_items+" "+reminder_name+"<br>";
  warning_count++;
 }
}
var options = {}
options.htmlBody = "REFER TO " + '<a href=\"' + 'http://www.google.com' + '">CARTEL MAINTENANCE SHEET</a><br />';
 var recipientsTO = "jim@nomadsailing.co.uk"+","+"joe.wallington01@gmail.com";
 var recipientsCC = "lou@nomadsailing.co.uk";

  if(warning_count > 0) {
  MailApp.sendEmail({to: recipientsTO,
                   cc: recipientsCC,
                   subject:"Cartel Equipment Alert",
                   htmlBody:"Equipment Service Alert:<br><br>"+msg+
                   "<br>REFER TO <a href='https://docs.google.com/spreadsheets/d/1Bq3xrK3d-SzltF9hZBkTziMscBN43oQTlyQdoUUW7MQ/edit?usp=sharing'>ALTOSTRATUS MAINTENANCE SHEET<a>"});
  }

};

0 个答案:

没有答案