Search code examples
emailgoogle-apps-scriptauto-incrementgoogle-formsresume

How to automatically assign/generate/increment an ID number into Google Form responses, so that respondents can access their own forms based on it?


I would like to set up a (Google) form-filling system, that essentially has to be accessed and filled two times (before and after the completion of a project). I would like to create a form one can return to by filling in an ID number.

For that, I would need a script that automatically generates an ID number for each respondent. I have found 'Google Apps Script for Form, Generate Unique ID Number', but I couldn't get it to work (I am not good at scripting yet). I would like to be able to decide how the ID numbers are generated (for example to have non-numeric characters as well, e.g. XYZ000000001, XYZ00000002, XYZ00000003, etc.)

The reason I want to do this is so that respondents can access their own responses based on the ID assigned to Them. I found two possible solutions, but again, I can't manage them. One code is the 'Class FormResponse' that fetches the existent information (if I understand it well enough), and the other is 'Generate unique Form URL for each respondent' which generates a unique URL for each respondent. That would work fine, but I still need the IDs for easier data maintenance.

This is a lot of code and I'm not sure if it makes sense to combine all of it. Perhaps there is an easier way to achieve what I want with a way simpler script. I will break down the process as I imagine it, into steps:

  1. Send a form to [email protected],[email protected],[email protected].
  2. For example, BB only has a project planned, so BB receives the form which asks: Is Your project planned or completed?
  3. BB chooses the first option and fills in the details.
  4. BB gets a unique ID which is inserted into the first column of the responses.
  5. The ID is sent back in a response email to BB (perhaps the linked script can be tweaked to send the unique ID).
  6. After a couple of months, BB has completed the project, so BB goes back to the form, either via the same email sent in step 1, or the same form embedded on a website.
  7. BB now chooses the second option, since the project is completed.
  8. The form asks for the ID number, BB fills it.
  9. All of BB's answers now go to the row with the matching ID, overwriting certain fields if necessary...

I am aware that this might be a bit complex, but any even partial answer accompanied by some snippets of code would be highly appreciated. I will gladly share it once I manage to compile the whole idea. :)


Solution

  • Google Forms doesn't allow respondents to search previous sent responses. The only way that they can access a previously submitted response is by the edit response URL. To get this URL programmatically, use getEditResponseUrl.

    You could send this URL by an email. For details see How to add "Edit Response" link to Google Forms emails?