Google apps script 添加带有脚本抛出的编辑器';无效电子邮件';并停止脚本
我正在使用Apps脚本生成一个文档,其中包含来自Google表单的响应,并将其存储在一个新文件夹中。我还允许用户根据他们提供的电子邮件提交表单编辑器访问权限Google apps script 添加带有脚本抛出的编辑器';无效电子邮件';并停止脚本,google-apps-script,google-docs,google-forms,google-workspace,Google Apps Script,Google Docs,Google Forms,Google Workspace,我正在使用Apps脚本生成一个文档,其中包含来自Google表单的响应,并将其存储在一个新文件夹中。我还允许用户根据他们提供的电子邮件提交表单编辑器访问权限 .addEditor(电子邮件) 这似乎适用于使用g-suite的Google域或公司域 但是,如果电子邮件不是基于谷歌的,脚本就会中断 “无效电子邮件:email@example.com“ 正在寻找跳过此错误并完成脚本的方法 function autoFillGoogleDocFromForm(e) { var Timestamp
.addEditor(电子邮件)代码>
这似乎适用于使用g-suite的Google域或公司域
但是,如果电子邮件不是基于谷歌的,脚本就会中断
“无效电子邮件:email@example.com“
正在寻找跳过此错误并完成脚本的方法
function autoFillGoogleDocFromForm(e) {
var Timestamp = e.values[0];
var email = e.values[1];
var file = DriveApp.getFileById('FILEID');
var folder = createfolder();
var copy = file.makeCopy(Name + ' - Document', folder);
var newId = copy.getId();
var doc = DocumentApp.openById(newId).addEditor(email);
var body = doc.getBody();
body.replaceText('{{Timestamp}}', Timestamp);
body.replaceText('{{Email}}', Email);
doc.saveAndClose();
}
正在寻找跳过此错误并获取脚本的方法
完成
function autoFillGoogleDocFromForm(e) {
var Timestamp = e.values[0];
var email = e.values[1];
var file = DriveApp.getFileById('FILEID');
var folder = createfolder();
var copy = file.makeCopy(Name + ' - Document', folder);
var newId = copy.getId();
var doc = DocumentApp.openById(newId).addEditor(email);
var body = doc.getBody();
body.replaceText('{{Timestamp}}', Timestamp);
body.replaceText('{{Email}}', Email);
doc.saveAndClose();
}
如果您正在寻找跳过错误的解决方案,则始终可以使用:
此代码段将尝试执行var doc=DocumentApp.openById(newId).addEditor(电子邮件)代码>
如果后者失败,那么它将只打开文档var doc=DocumentApp.openById(newId)代码>并继续执行其余代码。谢谢Marios,我确实希望代码的其余部分继续执行,因此如果电子邮件出现错误,它将继续完成替换文本function@EwanFarry谢谢你的反馈。请尝试我的更新解决方案。