收到服务错误:电子表格

时间:2017-11-03 09:38:35

标签: google-apps-script google-apps google-apps-script-editor

请您查看以下错误消息。

11/2/17 8:40 AM refreshStatus服务错误:电子表格(第8行,文件"代码")基于时间的11/2/17 8:41 AM。

我每天都会收到此错误电子邮件。

你能告诉我吗。

我的代码如下,请您检查并提出建议。

    function refreshStatus()
    {
    var sheet = SpreadsheetApp.getActiveSheet();
    var lastRow = sheet.getLastRow();
    var statusCol=6; 
for(i=2;i<=lastRow;i++)
{
var value = sheet.getRange(i, statusCol).getValue();
//Logger.log(value);
if(value == "Checked")
{
sheet.getRange(i, statusCol).setBackground('Green');
sheet.getRange(i, statusCol).setFontColor('White');
}
else
{
sheet.getRange(i, statusCol).setBackground('Red');
sheet.getRange(i, statusCol).setFontColor('White');
}
}
}


function mailer() 
{
//Logger.log(e);
var sheet= SpreadsheetApp.getActiveSheet();
var lastRow = sheet.getLastRow();
var value = sheet.getRange(lastRow, 10).getValue();
// 10th column contains the unique code
//Logger.log(value);
var values = sheet.getRange(lastRow, 3).getValue();
var values3 = sheet.getRange(lastRow, 4).getValue();
var values2 = sheet.getRange(lastRow, 1).getValue();
var values4 = sheet.getRange(lastRow, 5).getValue();
var values1 = sheet.getRange(lastRow, 2).getValue();
var formUrl="https://script.google.com/a/macros/lafargeholcim.com/s/AKfycbx8V31uCLtAAZWV4ictEvJyM6WIRDYz3tm6LOPlMNxy38VJSgs/exec?pkey="+value;
//Logger.log(formUrl);

MailApp.sendEmail({
              to: values,
              subject: "New Handover - "+values3+"",
              htmlBody: "<b>"+ 
              values3 +"</b> handovered to you.<p>By: "+
              values1 + "<p>Time: "+
              values2 + "<p>Description: "+
              values4 + '<p><form method="post" action="'+formUrl+'"><input type="submit" value="Checked"></form>'});

sheet.getRange(lastRow,13).setValue('EMAIL_SENT');


}
function backupMail()
{
var sheet = SpreadsheetApp.getActiveSheet();
var values=SpreadsheetApp.getActiveSheet().getDataRange().getValues();
for(i=3; i<values.length; i++)
  {
  if(values[i][12] == "")
  {
  var formUrl="https://script.google.com/a/macros/lafargeholcim.com/s/AKfycbx8V31uCLtAAZWV4ictEvJyM6WIRDYz3tm6LOPlMNxy38VJSgs/exec?pkey="+values[i][9];
  MailApp.sendEmail({
           to: values[i][2],
              subject: "New Handover(b) - "+values[i][0]+"",
              htmlBody: "<b>"+ 
              values[i][3] +"</b> handovered to you.<p>By: "+
              values[i][1] + "<p>Time: "+
              values[i][0] + "<p>Description: "+
  values[i][4] + '<p><form method="post" action="'+formUrl+'"><input type="submit" value="Checked"></form>'})
  var a=i+1;
  sheet.getRange(a,13).setValue('EMAIL_SENT(b)');
  }
else
{
Logger.log("ELSE");
}
}}


function pendingstatus()

{
var ss =SpreadsheetApp.getActiveSheet();
var values=SpreadsheetApp.getActiveSheet().getDataRange().getValues();
for (i=3; i<values.length; i++)
{
if (values[i][5] == "Pending")
{

var formurl="https://script.google.com/a/macros/lafargeholcim.com/s/AKfycbx8V31uCLtAAZWV4ictEvJyM6WIRDYz3tm6LOPlMNxy38VJSgs/exec?pkey="+values[i][9];
MailApp.sendEmail({
to: values[i][2],
subject: "Pending Handover - "+values[i][3]+"",
htmlBody: "<b>"+
values[i][3] +"</b> was handovered to you.<p>By: "+
values[i][1] + "<p> on: "+values[i][0] +" "+
 "<p>With Description: "+
values[i][4] + '<p>Please mark handover as checked as it is pending.' + '<p><form method="post" action="'+formurl+'"><input type="submit" value="Checked"></form>'})

var a=i+1;
ss.getRange(a,7).setValue('Reminder_Sent');

}
else
{
Logger.log("ELSE");
}

}
}

function maxExc() {
  var startTime= (new Date()).getTime();

  //do some work here

  var scriptProperties = PropertiesService.getScriptProperties();
 var startRow= scriptProperties.getProperty('start_row');
  for(var ii = startRow; ii <= size; ii++) {
    var currTime = (new Date()).getTime();
    if(currTime - startTime >= MAX_RUNNING_TIME) {
     scriptProperties.setProperty("start_row", ii);
      ScriptApp.newTrigger("maxExc")
               .timeBased()
               .at(new Date(currTime+REASONABLE_TIME_TO_WAIT))
              .create();
      break;
    } else {
      doSomeWork();
    }
  }

  //doSomeWork(); executes relatively quick less than 1 minute.

}

如果需要进行任何更改以避免错误,请告诉我们。

提前感谢您及时回复。

1 个答案:

答案 0 :(得分:-1)

我每晚都会收到这些错误。我写了很多GSuite脚本,我的收件箱被他们发了垃圾邮件。只是忽略它:)

除非脚本不起作用..