这是代码。我无法调试,因为它在被调查者提交表单时使用了触发器。
// This code opens the doc and names it what you wanted it named above. It also appends any other language to the title that you wish. My sample below will title each document as docName + 'for' + Lname or (OA Graduate Assistant Application for Last Name of user).
var copyId = DriveApp.getFileById(docTemplate)
.makeCopy(docName+' for '+ Lname)
.getId();
// Open the temporary document
var copyDoc = DocumentApp.openById(copyId);
// Get the document’s body section
var copyBody = copyDoc.getActiveSection();
//code that makes edits
copyBody.replaceText('keyTimestamp', Timestamp);
copyBody.replaceText('keyPemail', Pemail);
//define the source folder to save the file in
var dir = DriveApp.getFolderById(folderid);
//add this file to the source folder
dir.addFile(copyDoc);
copyDoc.saveAndClose();
指定的文件夹和我的整个google驱动器中没有存储文件。有什么问题?所有变量都是正确定义的(我只是省略了var语句)。
答案 0 :(得分:0)
如何关注以下脚本?
" addFile()"是一种类DriveApp的方法。因此,必须通过DriveApp的方法检索该文件。对于您的脚本,它使用" getFileById()"。
// This code opens the doc and names it what you wanted it named above. It also appends any other language to the title that you wish. My sample below will title each document as docName + 'for' + Lname or (OA Graduate Assistant Application for Last Name of user).
var copyId = DriveApp.getFileById(docTemplate)
.makeCopy(docName+' for '+ Lname)
.getId();
// Open the temporary document
var copyDoc = DocumentApp.openById(copyId);
// Get the document’s body section
var copyBody = copyDoc.getActiveSection();
//code that makes edits
copyBody.replaceText('keyTimestamp', Timestamp);
copyBody.replaceText('keyPemail', Pemail);
//define the source folder to save the file in
var dir = DriveApp.getFolderById(folderid);
//add this file to the source folder
dir.addFile(DriveApp.getFileById(copyId));
copyDoc.saveAndClose();
如果这不是解决办法,我道歉。