简体   繁体   中英

How to delay confirmation page in Google Forms until script has run?

I'm working in modifying a google form to process information from my team. I want them to provide information on New Projects and Existing Projects. If Existing Projects is selected, it displays a URL to take the user to another form. I want the confirmation page to only display the link to the next form if the user has selected “Existing Projects”.

I know previous answers on this site and from Google Help state that you cannot dynamically change the confirmation notice. However, I have written a function which takes the user response and changes the confirmation response using GAS .setConfirmationMessage(). However, this only takes effect using the onSubmit trigger, and the confirmation page is loading too quickly right now to change the information from the current response.

    function pageDisplay(){
       var form=FormApp.getActiveForm();
       var formResponses=form.getResponses();
       var lastFormResponse=formResponses.pop();
       var itemResponses=lastFormResponse.getItemResponses();
       var itemResponse=[]; //initialize array

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

     switch (itemResponse[0].toString()){
         case "Existing Project":
            form.setConfirmationMessage("Thank you now please visit URL");
            form.setConfirmationMessage(url);
          break;

        case "New Project":
           form.setConfirmationMessage("Thank you for your new information").setShowLinkToRespondAgain(true);
          break;

}}

Question : How can I slow down the loading of the confirmation page until after the script has run? Is this possible?

I am getting used to GAS but have no experience in HTML or webpage JS so please be detailed if it involves those. Thank you for your help!

Google Forms doesn't include a built-in feature to change published form behaviors like delaying the displaying of the confirmation page.

One alternative is to get control of the POST request to the Google Form app by using UrlFetchApp but this could unnecessarily over-complicate your a solution to be deployed as "production". If you still want to take this way, you should the use HTMLService to display a html form with a custom form submit action that will emulate the form action of the published Google Form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM