How to add “Edit Response” link to Google Forms emails?

前端 未结 9 1724
有刺的猬
有刺的猬 2020-12-05 02:46

I have a simple Google Form that collects data, and, using AppScript, sends confirmation emails to users who fill it out. After user submits the form, on confirmation, s/he

相关标签:
9条回答
  • 2020-12-05 03:17

    The answer that this wasn't possible by @Henrique Abreu was true until very recently. Google seems to have added getEditResponseUrl() to the FormResponse class and with that it becomes possible to use code like this to get the edit URL for a bunch of existing forms:

    function responseURL() {
     // Open a form by ID and log the responses to each question.
     var form = FormApp.openById('1gJw1MbMKmOYE40Og1ek0cRgtdofguIrAB8KhmB0BYXY'); //this is the ID in the url of your live form
     var formResponses = form.getResponses();
     for (var i = 0; i < formResponses.length; i++) {
       var formResponse = formResponses[i];
       Logger.log(formResponse.getEditResponseUrl());
     }
    }
    

    To make it automatically email the user as they respond one could add a trigger on form submit. As The situation I'm working with doesn't require people to log in with an apps account I don't have access to an email address automatically so I have a text question that captures the user's email address.

    It does ask the question about whether or not editing the forms is what you want. I've been grappling with the relative advantages of editing an existing response or sending a prefilled form using toPrefilledUrl() so that I can see how things have changed over time. I guess this comes down to the value that tracking this will provide you.

    0 讨论(0)
  • 2020-12-05 03:24

    --edit this is now possible. See other answers.

    After user submits the form, on confirmation, s/he will see a link to edit his/her response. I'd like to include that link as a part of the confirmation email

    That is not possible, period.

    That link is not accessible anywhere and one can't guess/construct it. But, there's some workarounds that might suit you (some suggested here that I'll re-phrase), e.g.

    Send a per-populated form link and have the user re-send it. You'd need to have some kind of control field (e.g. the username), so you can know and delete/ignore his older submits. Possibly automatically via a script.

    You could also develop and publish an apps-script GUI and send a link to this apps script plus a parameter that you generate where you can determine which entry you should edit. The down-side of this approach is that it's somewhat cumbersome and overkill to re-design the whole form on Apps Script. But again, it works.

    At last, you could open an "Enhancement Request" on Apps Script issue tracker and wait until they and Google Spreadsheet/Forms team get together to develop a solution.

    0 讨论(0)
  • 2020-12-05 03:26

    Great, script works! Thanks.

    For newbies, like me: Just paste the andre's code for function SendConfirmationMail(e) into your spreadsheet's code editor and set 'on form submit' trigger to run it. That's in spreadsheet script editor, not form script editor.

    You need to hack in some values. Read the code. For me the confusing one was the need to replace the ********COLUMN SEQUENCE EX 14****** with the sheet column number where you want the edit urls to end up. I used 39 which is one column more than my form was using up.

    However, I got runtime probs in this part:

    for (var i in headers) {
    
                value = e.namedValues[headers[i]].toString();
    
                // Do not send the timestamp and blank fields            
                if ((i !== "0") && (value !== "")) {
                    message += headers[i] + ' :: ' + value + "<br>";
                }
            }
    

    Dunno why, but I replaced it with this:

     for (var keys in columns) {
            var key = columns[keys];
            if ( e.namedValues[key]) {
            message += key + ' :: '+ e.namedValues[key] + "<br>"; 
            } 
        }
    

    Works for me.

    0 讨论(0)
  • 2020-12-05 03:27

    Here is a clear blog post that shows you how to do it step by step and explains what's going on under the hood for AppsScripts newbies:

    http://securitasdato.blogspot.com/2014/11/sending-confirmation-emails-from-google.html

    While collectively you can get there from the all the excellent answers provided here, the script from that post worked best for me.

    0 讨论(0)
  • 2020-12-05 03:27

    I don't think we have access to what that value is through the Spreadsheet API (which means Apps Script doesn't have it either). The closest I can think of would be the "key" value in this feed. You'd have to test to find out though. There's no other alternative that I know of other than accessing the Spreadsheet API directly. So first, you'd have to get the last row through the api use ?reverse=true&max-results=1

    0 讨论(0)
  • 2020-12-05 03:35

    If you are using Google Apps your responders can edit there form responses.

    See: How to Edit Form Responses

    0 讨论(0)
提交回复
热议问题