Error running Google Apps Script: Cannot invoke undefined method "getItemResponses"

Asked 2 years ago, Updated 2 years ago, 45 views

Thank you for your continuous support.
Now, I was writing a form script.
Previously, the contents of the form were sent to the email without any problems in the script below, but an error occurred.

The error is as follows:

Undefined method ggetItemResponses を cannot be invoked.

The source code is as follows:

function submitForm(e){
  varitemResponses=e.response.getItemResponses();
  var message=';
  for (vari=0;i<itemResponses.length;i++) {
    variableResponse=itemResponses[i];
    varquestion=itemResponse.getItem().getTitle();
    var answer = itemResponse.getResponse();
    message+=(i+1).toString()+'.'+question+':'+answer+'\n';
  }
  var address='[email protected]';
  var title='[Request accepted]';
  var content='Your request has been received with the following information:\n\n'+message;
  GmailApp.sendEmail(address, title, content);
}

The trigger was successfully configured.What is wrong with the source code?
The trigger error rate is 100%.

google-apps-script

2022-09-30 15:04

3 Answers

If you search in the error message that appears, you will find several articles about similar symptoms.
The workaround is to delete and reconfigure the trigger.
Also, when you reconfigure it, you will see a dialog about adding permissions, so please re-approve it.

Note:
Google Apps Script cannot invoke the method "getItemResponses". When appears -Qiita
Talk about Google form auto-submission scripts that suddenly require approval


2022-09-30 15:04

It seems to be a Scope problem.Re-attach the trigger by adding the following in the comment.

//FormApp.getActiveForm()

For more information, please refer to the answers.
When I set the trigger on the new trigger settings screen of the Google form script, the event did not cross well.Is the previous script no longer available?
(Handy matsu is referring to it, but the URL is too long to open, so I will reprint it.)


2022-09-30 15:04

It's not the answer, but I'm stuck with the same phenomenon (although I'm a beginner) (I think I'm trying to do the same thing because the scripts are almost the same),
「// Add FormApp.getActiveForm()
I also did "Delete, recreate, authorize"
I tried both Form to Script, spreadsheet to Script, and
Failed to execute due to an error...
This questioner, if it has been solved, I am writing to ask you how to do it.


2022-09-30 15:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.