0

I'm trying to add something extra to my google form, ie. when the user clicks submit I would like to direct him to another page but only when he chooses more then 4 on a linear scale answer.

Thank you in advance!

Here's my code:

 var form = FormApp.openById('1PXav2ChPZjYU0qEuKCE_fabv6B4jyPAF5VeGZfz3PYg');
 var formResponses = form.getResponses();
 for (var i = 0; i < formResponses.length; i++) {
   var formResponse = formResponses[i];
   var itemResponses = formResponse.getItemResponses();

   for (var j = 0; j < itemResponses.length; j++) {
     var itemResponse = itemResponses[j];
   }
 }

if(itemResponses[0].getResponse() >= 4){
  Logger.log('more then 4')
  window.open('https://www.google.pl') //here it'd direct user to different page
}else{
  Logger.log('less then 4')
}
Murakami
  • 3,474
  • 7
  • 35
  • 89
  • Window is not a valid class in google apps script, i think that's the problem – jbra95 Mar 13 '18 at 11:37
  • Probably it is, but what is valid in GAS? Or where to check that? – Murakami Mar 13 '18 at 11:38
  • Is this different than your other question https://stackoverflow.com/questions/49243754/redirecting-user-after-submitting-the-form-to-other-website-in-google-apps-scrip ? It doesn't look different. – tehhowch Mar 13 '18 at 14:30
  • Well, it is similar. I had not code written before. Definately I'm going to delete previous one. Thank you! – Murakami Mar 13 '18 at 14:37
  • As I mentioned on the other question you asked: to do this you will need to use a custom form page. Implement it as a combination of Google Apps Script (deployed as webapp) with HtmlService generating the page. Apps Script would allow the simple interface to google services you are currently using it for, and could receive the input from your custom form in order to submit it as the response to an actual Google Form. In the page's JavaScript, you would implement your form / event handling, things like `window.open`, etc – tehhowch Mar 13 '18 at 14:43
  • Is there any docs or tutorials available for that? It seems quite complicated – Murakami Mar 14 '18 at 08:39
  • Ok, I think I get it, but how my custom form's submit button will fire submit button of an actual google form? – Murakami Mar 14 '18 at 10:49

0 Answers0