【问题标题】:Google Apps script: "We're sorry, a server error occurred. Please wait a bit and try again"Google Apps 脚本:“很抱歉,发生服务器错误。请稍候,然后重试”
【发布时间】:2013-11-02 10:42:11
【问题描述】:

我正在使用 Google Apps 脚本设置电子表格合并到将通过电子邮件发送的发件人信件。我复制了一个类似的脚本并添加了我的信息。 每次我尝试保存它时,我都会收到“我们很抱歉发生服务器错误。请稍候,然后重试。”

//  dixie@yellowdogknitting.com
//  Job Offer Letter

//  Get template from Google Docs and name it
var docTemplate = "1Y5ohbBWPeLSvNijge6I3ueQpulFzeZTky7853sKGSj8";
var docName = "HR_2_Job_Offer_form_letter";

//  When Form Gets Submitted
function onFormSubmit(e) {

//  Get information from form and set our variables

var email_address = e.values[10];
var date = e.values[1];
var first_name = e.values[2];
var last_name = e.values[3];
var job_title = e.values[11];
var status = e.values[13];
var hourly_wage = e.values[14];
var start_date = e.values[15];

//  Get document template, copy it as a new temp doc, and save the doc's id
var copyId = DocList.getFileById(docTemplate)
        .makeCopy(docName+' for '+first_name last_name)
        .getId();

//  Open the temporary document
var copyDoc = DocumentApp.openById(copyId);

//  Get the document's body section
var copyBody = copyDoc.getActiveSection();

//  Replace place holder keys, in our google doc template
copyBody.replaceText('keyTodaysDate', date);
copyBody.replaceText('keyFirstName', first_name);
copyBody.replaceText('keyLastName', last_name);
copyBody.replaceText('keyJobTitle', job_title);
copyBody.replaceText('keyStatus', status);
copyBody.replaceText('keyHourlyWage', hourly_wage);
copyBody.replaceText('keyStartDate', start_date);

//  Save and close the temporary document
copyDoc.saveAndClose();

//  Convert document to PDF
var pdf = DocList.getFileById(copyId).getAs("application/pdf")'

//  Attach PDF and send the email
var subject = "Job Offer";
var body = "Here is the Job Offer for " + first_name last_name + "";
MailApp.sendEmail(email_address, subject, body, {htmlBody: body, attachments: pdf});

//  Delete temp file
DocsList.getFileById(copyId).setTrashed(true);
}

【问题讨论】:

标签: google-apps-script


【解决方案1】:

当幕后引发某种 Javascript 错误时,就会发生这种情况。

为了确定哪一行有错误,在代码的第一行放置一个断点(你可以通过点击行号的左边来做到这一点。)

然后单步执行代码,看看server error 何时弹出。然后我们可以帮助您找出那条特定线路的问题。

【讨论】:

    猜你喜欢
    • 2013-01-13
    • 1970-01-01
    • 2019-08-13
    • 1970-01-01
    • 2021-01-21
    • 2017-05-02
    • 1970-01-01
    相关资源
    最近更新 更多