0
votes

I create a Google form using a work account and make it "Restrict to [domain.com] users". Now I can collect the email address of person who submit the response firstly. And then here comes my question: Is it possible to collect the email address of anyone else who modify the previous response?

For example the situation like this, person A fill out a form and he share the edit link to his teammate person B, then person B update the response on that previous form. I wonder if there is any solution to retrieve the email of person B (without asking for their e-mail address in the form).

I tried to use getRespondentEmail(), however it doesn't work. It always return the email address of person A.

1
Did you try using an "On Form Submit" trigger with Session.getActiveUser()?Alan Wells
@SandyGood Yes. I also tried using "On form Submit" trigger with Session.getActiveUser().getEmail() and Session.getEffectiveUser().getEmail(). Both they will return the same account as me, the owner of this form/script.Kenny Qi
It sounds as if you are running the script as you and not the user. Is it deployed/published? If yes, did you set it to run as yourself or the user?Karl_S
@Karl_S It isn't deployed/published. When the form Submit trigger fires, script passes the function an event object. I can see the field Username in e got nothing if the user whoever edited the response. @_@Kenny Qi
As I understand it,unless the person running the script is prompted to authorize the script, both 'Session.getActiveUser().getEmail()' and 'Session.getEffectiveUser().getEmail()' are run as the person who created the trigger, not the person running the script. Users cannot authorize scripts on some triggers, such as on edit, and, I believe, on form submit.Karl_S

1 Answers

0
votes

Please try using getEditResponseUrl() method.

This method, as mentioned in the documentation,

Generates a URL that can be used to edit a response that has already been submitted, even if the Form.setAllowResponseEdits(enabled) setting is disabled. Anyone who visits the link can edit the response, although they need an account with access to the form if the Form.setRequireLogin(requireLogin) setting is enabled. If the Form.setCollectEmail(collect) setting is enabled, the form records the email address of the user who edited the response instead of the email address of the original respondent.