1

I wrote a script for a Google Sheet that emails a user some specific info relevant to them alone. It works fine with the onOpen trigger, but I don't want them to have to open the sheet each time.

It would be easier to submit a form request and then receive the email but I'm not sure how to do that. I'm sure this is very basic so apologies for that, I'm new to this.

Basically I would like to form to ask if they want to receive an email with the info, and if they say yes, it triggers the script.

1
  • Take a look at this tutorial it shows you how to manage form responses using Google Apps Scripts, the script can be triggered onFormSubmit(), so that if the "want an email?" box is marked, the user who submitted the form gets the email. One detail, you would need to ask the user to enter their email address in the form, there's no way to retrieve it just from the responses. Commented Sep 10, 2019 at 14:28

2 Answers 2

2

There are two ways to do this. The first is to:

  1. Link the form responses to the spreadsheet
  2. Add the installable trigger on form submit to the spreadsheet on the function you want to run.
  3. Get the necessary information from the event object to see who submitted the form.

The second way is to:

  1. Place a script on form.
  2. Put an onFormSubmit() trigger on the form
  3. Have the form open the spreadsheet - SpreadsheetApp.openById()
  4. Copy paste the spreadsheet code into the form, making adjustments, so it will run (will mostly be how to get the user data)

If you would like this to only occur if the respondent asks, you can place a yes/no question on the form and check the answer. You can also have a questionless form that only collects emails, if you just want them to submit it to trigger an email.

Sign up to request clarification or add additional context in comments.

Comments

-1

there might be useful to do a template with a form with two buttons, 'Yes' or 'No'. If they hit 'Yes' you can hit an API in your platform to run script.

Maybe you can use a redis or some database to save the preferences of this user.

Hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.