Mic*_*son 4 javascript parameters methods google-apps-script google-drive-api
我是脚本新手,想知道是否可以获得有关问题的帮助。我目前正在尝试从 Google 表单提交中自动填写 Google 文档。我过去曾成功进行过一次小测试,但自从第二次尝试更大的形式后,我遇到了以下错误:
“异常:参数 (String,DriveApp.File) 与 DriveApp.File.makeCopy 的方法签名不匹配”
我并不清楚这告诉我什么。我所知道的是,我没有做任何与上次小规模测试不同的事情,因此我正在运行的脚本表面上看起来很可靠,所以我希望有人可以帮助我指出问题所在。这是脚本:
function autoFillFormFromDoc(e) {
var clientCode = e.values[1];
var email = e.values[2];
var warningSigns = e.values[3];
var internalCopingStrategies = e.values[4];
var peopleAndSocial = e.values[5];
var peopleWhoCare = e.values[6];
var creatingSafety = e.values[7];
var clientName = e.values[8];
var date = e.values[9];
var templateFile = DriveApp.getFileById("1Vs8y3eZbyBlef8HlV7v9nhSRvaH39Cg5P0Q5zhpZBA");
var templateResponseFolder = DriveApp.getFileById("1OxsOwU6rAvohqRqDVOfH_f70kvu30HZp");
var copy = templateFile.makeCopy(clientName, templateResponseFolder);
var doc = DocumentApp.openById(copy.getId());
var body = doc.getBody();
body.replaceText("{{ClientCode}}", clientCode);
body.replaceText("{{Email}}", email);
body.replaceText("{{WarningSigns}}", warningSigns);
body.replaceText("{{InternalCopingStrategies}}", internalCopingStrategies);
body.replaceText("{{PeopleAndSocial}}", peopleAndSocial);
body.replaceText("{{PeopleWhoCare}}", peopleWhoCare);
body.replaceText("{{CreatingSafety}}", creatingSafety);
body.replaceText("{{ClientName}}", clientName);
body.replaceText("{{Date}}", date);
doc.saveAndClose();
}
Run Code Online (Sandbox Code Playgroud)
File.makeCopy(name, destination)需要两个参数
name类型string和destination类型的folder该脚本destination使用 type进行调用file。因此它会出错
参数 (String,DriveApp.File) 与 DriveApp.File.makeCopy 的方法签名不匹配
获取folder而不是file:
var templateResponseFolder = DriveApp.getFolderById("[FOLDER_ID]");
Run Code Online (Sandbox Code Playgroud)