尝试将Google翻译成PDF文档,然后发送电子邮件并发现脚本错误

时间:2014-07-19 19:38:08

标签: google-apps-script

因此,我试图将谷歌表单中的信息转换为谷歌文档,然后转换为PDF文件,然后在提交时将电子邮件转换为初始发件人。

我已编写代码,并且在创建要发送的新文档后遇到问题。代码找不到需要填写的文档。 下面是我收到的错误后面的代码。它在第23行。

var docTemplate = "1mlAPTZ_UH1I3bRfgqiOVDI7PKgDXV-tGMpXLIwFoPjQ";
var docName = "Downtime";
function onFormSubmit (e) {
var Email_Address = e.values[2];
var Character_and_Player_Name = e.values[1];
var Major_Events_for_your_Character_Last_Session = e.values[3];
var Feedback_and_Questions = e.values[4];
var Major_Downtime_Action_A = e.values[5];
var Major_Downtime_Action_B = e.values[6];
var Major_Downtime_Action_C = e.values[7];
var Minor_Action_A = e.values[8];
var Minor_Action_B = e.values[9];
var Minor_Action_C = e.values[10];
var Minor_Action_D = e.values[11];
var Minor_Action_E = e.values[12];
var Minor_Action_F = e.values[13];
var Pack_Downtime = e.values[14];
var XP_Spends = e.values[15];
var Renown = e.values[16];
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(docName+' for '+Character_and_Player_Name)
.getId();
var copyDoc = DocumentApp.openByID(copyId);
var copyBody = copyDoc.getActiveSection();
copybody.replaceText('keyCharacterandPlayerName', Character_and_Player_Name);
copybody.replaceText('keyMajorEventsforyourCharacterLastSession', Major_Events_for_your_Character_Last_Session);
copybody.replaceText('keyFeedbackandQuestion', Feedback_and_Questions);
copybody.replaceText('keyMajorDowntimeActionA', Major_Downtime_Action_A);
copybody.replaceText('keyMajorDowntimeActionB', Major_Downtime_Action_B);
copybody.replaceText('keyMajorDowntimeActionC', Major_Downtime_Action_C);
copybody.replaceText('keyMinorActionA', Minor_Action_A);
copybody.replaceText('keyMinorActionB', Minor_Action_B);
copybody.replaceText('keyMinorActionC', Minor_Action_C);
copybody.replaceText('keyMinorActionD', Minor_Action_D);
copybody.replaceText('keyMinorActionE', Minor_Action_E);
copybody.replaceText('keyMinorActionF', Minor_Action_F);
copybody.replaceText('keyPackDowntim', Pack_Downtime);
copybody.replaceText('keyXPSpends', XP_Spends);
copybody.replaceText('keyRenown', Renown);
copyDoc.saveAndClose();
var pdf = DocsList.getFileByID(copyID) .getAs("application/pdf");
var subject = "Downtime Copy"
var body = "Here is a copy of your submitted Downtime for Rage Across the Dunes for " + Character_and_Player_Name;
MailApp.sendEmail(Email_Address, subject, body, {htmlBody: body, attachments: pdf});
DocsList.getFileById(copyID).setTrashed(true);
} 

TypeError:在对象DocumentApp中找不到函数openByID。 (第23行,文件“代码”)

任何帮助都会很棒我正在学习,所以任何帮助都会有用。

1 个答案:

答案 0 :(得分:0)

更改资本" D"小写" d"。

ID到Id

DocumentApp.openByID(copyId)

需要:

DocumentApp.openById(copyId)