lundi 13 avril 2015

Execution failed: TypeError: Cannot find function getResponseForItem in object

I am hoping for some help with the following instructions I was trying to use with the Google add-on Form Notifications. I followed the directions on this page: https://developers.google.com/apps-script/quickstart/forms-add-on#set_it_up


I was positive I had copied and pasted the code right and did the test. I was able to get the Form Submission Email Notification just fine and it works, but when I tried testing the Respondent Email Notification by submitting the form with my own email address I did not get the Respondent Email Notification.


When I run the Execution Transcript I get this:



[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]


I checked the line in the "Code" file and can see this:



}

/**
* 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()
});
}
}


The code that says var respondentEmail = response.getResponseForItem(emailItem) is line 274


Any help would be greatly appreciated, I am a novice at this and am trying to learn some tricks. Thank you!


Aucun commentaire:

Enregistrer un commentaire