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

查看:53
本文介绍了如何让 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.

查看原始问题/问题的父线程

推荐答案

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

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. 选择编辑">当前项目的触发器".您会看到一个带有消息 未设置触发器的面板.单击此处立即添加一个.
  2. 点击链接.
  3. 运行下,选择您希望触发器执行的函数.(在本例中为 onFormSubmit().)
  4. 事件下,选择来自电子表格.
  5. 从下一个下拉列表中,选择On form submit.
  6. 点击保存.
  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天全站免登陆