我希望有人可以帮助我,我想做的是让 Google 表单创建一个新文档,并在编辑表单时通过电子邮件发送该 pdf。
我了解当您编辑表单时,电子表格中的脚本不会运行,因此我已将脚本放入表单中,这就是我遇到问题的地方。我无法让脚本读取表单上重新提交的值,它只是在返回时不断出现“未定义”
这是我到目前为止得到的脚本。
function Test(e) {
var form = FormApp.openById('****Form Key****'); //Enter Form ID here
var docTemplate = "***doc to be used***";
var docName = "***Name of document***";
var formResponse = form.getResponses();
var one = e.response; //I have tried e.value but does not pull through
var two = e.response; // Column 2
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(docName)
.getId();
// Open the temporary document
var copyDoc = DocumentApp.openById(copyId);
// Get the document’s body section
var copyBody = copyDoc.getActiveSection();
copyBody.replaceText('one', one);
copyBody.replaceText('two', two);
// Save and close the temporary document
copyDoc.saveAndClose();
// Convert temporary document to PDF by using the getAs blob conversion
var pdf = DocsList.getFileById(copyId).getAs("application/pdf");
//Sends the email
var email_Address = "***Email Address***"
var subject = "***Subject";
var body = "**Body***";
MailApp.sendEmail(email_Address, subject, body, {attachments: pdf});
}}
任何帮助将不胜感激,因为我已经坚持了一段时间。谢谢你。