您提供的"修复"(test_onformsubmit)代码,每次电子表格中有新数据时,我都必须手动运行它.我希望它在提交表单时自动将pdf发送到电子邮件.有办法吗?因为手动方式运行代码完全像它应该的那样,但我希望这是一个自动事件,所以我不需要做任何事情.
我使用Google表单教程调整表单数据以合并为PDF,然后发送到电子邮件.我尝试运行脚本时收到以下错误消息:
TypeError:无法从undefined中读取属性"values".(第11行,文件"代码")
我不知道如何解决这个问题.我在网上搜索了一个答案.这是脚本的副本.我标记了脚本出错的2行:
var docTemplate = "1ZSqmId2BBjtz6PmgQEmusjnkHGsFKD1CBSq0rrQk6Kc";
var docName = "TestCertificate";
// When Form Gets submitted
function onFormSubmit(e) {
//Get information from form and set our variables
var email_address = "EMAIL@example.com";
//**(THIS IS WHERE THE ERROR IS OCCURRING ON THESE 2 LINES BELOW!)**
var full_name = e.values[2];
var Activity = e.values[3];
// Get document template, copy it as a new temp doc, and save the Doc’s id
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(docName+' for '+full_name)
.getId();
// Open the temporary document …
Run Code Online (Sandbox Code Playgroud)