【问题标题】:Failed to produce PDF file upon submitting Google form提交 Google 表单时无法生成 PDF 文件
【发布时间】:2021-09-01 05:46:23
【问题描述】:

我正在尝试创建一个函数,在提交 Google 表单时,它将基于模板文档生成 PDF。但是,当我尝试运行脚本时,仍然出现错误,显示 error in line 2 e.namedvalue(e)

function afterFormSubmit(e) {
  const info = e.namedValues;
  createPDF(info);
}

function createPDF(info) {
  const pdfFolder = DriveApp.getFolderById("1BSBIOPWFoc7o2nbX8XT23C85_pBq02VE");
  const tempfolder = DriveApp.getFolderById("1xSl7VhVwHAmIcVOdXVUlzwZcZ27q3hqU");
  const templateDoc = DriveApp.getFileById("1vc7rTRU88LDF07hJs5Waf4OIWy2pAeoFNkB8UBpDnqI");
  const newTempFile = templateDoc.makeCopy(tempfolder);
  const opendoc = DocumentApp.openById(newTempFile.getId())
  const body = opendoc.getBody();
  body.replaceText("{dor}", info['Timestamp'][0]);
  body.replaceText("{fn}", info['Name ( Nama )'][0]);
  body.replaceText("{nric}", info['NRIC/ID/PASSPORT ( No kad pengenalan/pasport )'][0]);

  const blobPDF = newTempFile.getAs(MimeType.PDF);
  const pdfFile = pdfFolder.createFile(blobPDF).setName(info['Name ( Nama )'][0] + " " + info['Timestamp'][0]);
}

【问题讨论】:

  • 你是怎么运行这个函数的,你有没有安装 afterFormSubmit 作为一个可安装的触发器?
  • 是的...已经在表单提交后放置了触发器。

标签: javascript pdf google-apps-script google-forms


【解决方案1】:

这似乎是一个错误。 You can find the issue here。要提高其优先级,请单击标题左侧的星号 (☆)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 2016-11-26
    • 1970-01-01
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多