Getting the e-mail of someone who clicked on a button? - google-apps-script

Not sure if this is even possible, but my (admittedly basic and tertiary) Googling has turned up a lack of results.
Is it possible to fetch the e-mail address of someone who clicks a button?
I'm trying to make a check-out spreadsheet that has a few functionalities Google Forms does not offer: specifically, graying out options in a list while those options are unavailable. I don't want people ignoring an e-mail box that they're meant to type in, or using another person's email, but I can't figure out if there is or is not a way to get the e-mail of someone who clicks a button.
Thanks in advance.

Shabnam got it.
[currentUser=Session.getActiveUser().getEmail()]
if you missed his comment.

Related

Can I use a user-entered text value in one section of a Google Form to populate checkbox options in the next section?

I'm trying to figure out if this is possible and if so any help on how to make it happen would be amazing. If not, I'd love to get an idea why it's not possible. I'm a novice and looking to learn! :)
I want to take a text response to one question in the first section of a Google Form and use that to populate checkbox options from a Google Sheet in the next section.
Basically, people check equipment out from my office for use with students and they can submit the form for extensions. I sometimes get confusing responses and would like to give them checkbox options based off the students' ID they enter in the first question.
Is any response information even available to use before the form is submitted?

How to record data that is in a hidden section with prefilled link Google Form

How to record data that is in a hidden section with prefilled link Google Form
I have a form with 3 sections. The first section is for the user to input answers, after this section the users will be redirected to the third section and skip the second section. The second section is a hidden section that users will never redirected to this section. The third section contains only description then submit the form.
I prefilled the input in the second section using Google Form feature, then share the link to people.
After the user submits, I expect all input to be recorded to Spreadsheet (including the input in the second section), but actually it only records the first and third section. The section which the user has never visited is not recorded.
So, how can I still record the data in the hidden section even when the user has never visited?
Thanks in advance!
The Forms Service allows you to use Google Apps Script to access users' responses to a form. If the user hasn't responded, there will be no response. You can't access a response that doesn't exist. If you are prefilling the response yourself, may I ask why you need to record your own prefilled response?
Thanks for clarifying #Fanny Hasbi. Since you are only using the hidden section to store constant data and not user input, you would be better off passing your data to whatever script you are running on form submit.
I'm running into this exact same issue, and I'd love to find a solution where this is possible. However, in the meantime, I've found a workaround and I wanted to share it here, even though it's been some time since your original question.
Instead of creating the question that you need for internal tracking info as a text item, instead create it as a multiple choice item, with only a single answer. Pre-fill that answer with the URL, and make the answer required. When the user accesses the Form, the answer will be chosen, and they won't be able to edit the text.
This is obviously less elegant than having a hidden section where the user doesn't see the internal data, but given Forms' limitations, this may be the best option for now. Here's how I have it set up in my script:
form.addMultipleChoiceItem()
.setRequired(true)
.setTitle('ID')
.setHelpText('(for internal tracking purposes only)')
.setChoiceValues([internalId]);
When you create the response for the prefilled URL, it's the exact same method as creating a response for a text item, so your script wouldn't need changing in that regard.
Hope that helps someone!

How do I keep a user from double clicking a link in an email?

When users request a password reset, they get an email with a link to generate a password reset code. This link is valid for 24 hours and can be re-used within the 24 hours to generate a new code if the first is lost or forgotten. When users double click the link, two codes are getting generated, leading to user confusion about which to use (the second code invalidates the first code with the way it has been developed).
Since the link in the email is just an html a tag, I'm not sure how I can keep users from double clicking the link.
This sounds like you're facing the XY problem. Your actual issue is that users get confused by visits in a quick succession causing a code that was just generated to be invalid, rather than the fact that the link can be clicked twice.
From a security point of view, these kind of links should really be single-use, and the user should request a new e-mail if they want to perform the action again. Assuming this is something you're forced to do, I believe the best compromise would be to limit code generation to a time frame, so visits within, let's say, 5-10 seconds would result in the same code being shown to the user, based on the server's time.
Implementing any CSS based solution for this that'd work across every e-mail client out there is challenging enough (if at all possible), and I doubt any self-respecting e-mail client is going to let you run any sort of JavaScript to intercept the event.
The following works in a modern browser on an actual web page, but this is not just a bad idea, it's also probably not going to work if you try to use it in an e-mail. I'm providing it here just for the sake of completeness, showing that it's somewhat possible, but please do not rely on this to fix the underlying issue.
<style>a:focus { pointer-events: none }</style>
<p>This is some text, here's a link you can't double click by the way.</p>

Is it possible to generate an autofill script for Google Forms?

I want to create a script to autofill based on what the respondent is filling out in a short answer or even just suggest text in a dropdown.
For example, there are over 300 different codes, which makes scrolling through that drop down list very annoying.
I want the script to had the ability to suggest an autofill once a user is attempting to type in an answer. For example, typing "T00F1..." would suggest autofilling the rest to "T00F17T0"
That way i prevent that the respondent write wrong the code
If it is not possible, what alternatives do you recommend to generate this type of forms?

Placing a checkbox submission into html eblast

I am trying to send an eBlast from mailchimp with a form embedded with checkboxes that when the button is pressed it sends a reply with whatever box they have chosen. Then their responses would be put into a google excel sheet so we know who is RSVPing. Is there a way to do this? Maybe there is an easier way and Im going about it wrong. Would love your guys help. Thanks
Forms in emails are only supported by a handful of email clients. An easier option/method would be to take them to a landing when a user clicks on yes, no or rsvp button. That page can give the right confirmation measage depending on what option a user has chosen.