Javascript 执行失败:TypeError:在对象中找不到函数getResponseForItem
我希望下面的说明能对我在Google附加表单通知中的使用有所帮助。我遵循了本页上的说明: 我确信我复制并粘贴了正确的代码,并进行了测试。我能够获得表单提交电子邮件通知,这很好,但当我尝试通过提交带有我自己电子邮件地址的表单来测试响应者电子邮件通知时,我没有收到响应者电子邮件通知 当我运行执行记录时,我得到:Javascript 执行失败:TypeError:在对象中找不到函数getResponseForItem,javascript,forms,google-forms,Javascript,Forms,Google Forms,我希望下面的说明能对我在Google附加表单通知中的使用有所帮助。我遵循了本页上的说明: 我确信我复制并粘贴了正确的代码,并进行了测试。我能够获得表单提交电子邮件通知,这很好,但当我尝试通过提交带有我自己电子邮件地址的表单来测试响应者电子邮件通知时,我没有收到响应者电子邮件通知 当我运行执行记录时,我得到: [15-04-13 14:22:39:887 EDT] FormApp.getActiveForm() [0.245 seconds] [15-04-13 14:22:40:023 EDT]
[15-04-13 14:22:39:887 EDT] FormApp.getActiveForm() [0.245 seconds]
[15-04-13 14:22:40:023 EDT] FormApp.getActiveForm() [0.083 seconds]
[15-04-13 14:22:40:057 EDT] Starting execution
[15-04-13 14:22:40:489 EDT] FormApp.getActiveForm() [0.425 seconds]
[15-04-13 14:22:40:726 EDT] PropertiesService.getDocumentProperties() [0.236 seconds]
[15-04-13 14:22:40:742 EDT] (class).getProperty([respondentEmailItemId]) [0.013 seconds]
[15-04-13 14:22:40:804 EDT] Form.getItemById([1914529909]) [0.061 seconds]
[15-04-13 14:22:40:807 EDT] Execution failed: TypeError: Cannot find function getResponseForItem in object [object Object]. (line 274, file "Code") [0.742 seconds total runtime]
我检查了“代码”文件中的行,可以看到:
}
/**
* Sends out respondent notificiation emails.
*
* @param {FormResponse} response FormResponse object of the event
* that triggered this notification
*/
function sendRespondentNotification(response) {
var form = FormApp.getActiveForm();
var settings = PropertiesService.getDocumentProperties();
var emailId = settings.getProperty('respondentEmailItemId');
var emailItem = form.getItemById(parseInt(emailId));
var respondentEmail = response.getResponseForItem(emailItem)
.getResponse();
if (respondentEmail) {
var template =
HtmlService.createTemplateFromFile('RespondentNotification');
template.paragraphs = settings.getProperty('responseText').split('\n');
template.notice = NOTICE;
var message = template.evaluate();
MailApp.sendEmail(respondentEmail,
settings.getProperty('responseSubject'),
message.getContent(), {
name: form.getTitle(),
htmlBody: message.getContent()
});
}
}
表示var respondentEmail=response.getResponseForItem(emailItem)的代码是第274行
任何帮助都将不胜感激,我是这方面的新手,正在尝试学习一些技巧。谢谢大家! 您的
getResponseForItem
定义在哪里?@webduvet我希望我的回答正确(正如我所说,我是新手)。在网页链接上给出的代码中,它为表单设置了一个侧栏,允许我在侧栏中从下拉列表中选择电子邮件地址(对于我在表单中为电子邮件地址设置的列),在说明中,它没有说明我需要更改代码本身,只是侧栏中的信息。我不知道在哪里可以找到它的定义。我应该在网页链接上给出的代码中包含它(所有代码都列在该页面上)。设置完成后,它会为表单设置一个侧栏,让我在侧栏中从下拉列表中选择电子邮件地址(对于我在表单中为电子邮件地址设置的列),并更改电子邮件响应的文本。在说明中,它没有说明我需要在脚本编辑器中更改代码本身,只是侧边栏中的信息。