如何让onFormSubmit自动触发? [英] How to get onFormSubmit to trigger automatically?

查看:425
本文介绍了如何让onFormSubmit自动触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您提供的修复(test_onformsubmit)代码,每当电子表格中有新数据时,我都必须手动运行它。我希望它在提交表单时自动将PDF发送到电子邮件。有没有办法?因为手动方式完全按照它应该运行的代码运行,但是我希望这是一个自动事件,所以我不必做任何事情。

The "fix" (test_onformsubmit) code you gave, I have to manually run it every time there is new data in the spreadsheet. I was wanting it to automatically send the pdf to email when Form is submitted. Is there a way? Because the manual way runs the code exactly like its supposed to, but I want this as an automatic event so I don't have to do anything.

请参阅父级原问题的线程

推荐答案

阅读了解触发器。这个函数是一个可安装触发器,因此您需要将它设置为在提交表单时运行。这很容易 - 我原以为Forms教程会遍历它。

Read Understanding Triggers. This function is an Installable Trigger, so you need to set it up to run when a form is submitted. It's easy - I would have thought a Forms tutorial would have walked through it.

在脚本编辑器中:


  1. 选择编辑>当前项目的触发器。您会看到一个包含 No triggers设置消息的面板。点击此处立即添加一个。

  2. 点击链接。

  3. 运行你想要通过触发器来执行。 (这是 onFormSubmit(),在这种情况下。)

  4. 事件下,选择<电子表格。

  5. 从下一个下拉列表中选择在表单提交
  6. em> Save 。
  1. Choose Edit > Current project's triggers. You see a panel with the message No triggers set up. Click here to add one now.
  2. Click the link.
  3. Under Run, select the function you want executed by the trigger. (That's onFormSubmit(), in this case.)
  4. Under Events, select From Spreadsheet.
  5. From the next drop-down list, select On form submit.
  6. Click Save.

从这时开始,只要将表单提交给电子表格,就会触发该函数。

From this point on, the function will be triggered whenever a form is submitted to the spreadsheet.

如果您打算分享您的脚本,每个收件人都需要重复这些步骤。

If you plan to share your script, each recipient will need to repeat these steps.

另外,您应该更改脚本中的电子邮件设置,以便它适用于任何人。

As an aside, you should change the email setting in your script, so it will work for ANYONE.

var email_address = Session.getActiveUser().getEmail();

这篇关于如何让onFormSubmit自动触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆