【发布时间】:2021-10-10 20:52:56
【问题描述】:
我给您写信是因为我遇到了基于 Google 表单提交(或发送 GForm 时的新 GSheet 条目)的自动电子邮件脚本的问题。流程简述:
我有一个链接到 Data Studio 和 Power BI 仪表板的 Google 表单 (here's similar one)。根据进入电子表格的数据,使用破折号中的计算字段(日期、ActionID、代码、ID、位置等)自动预填充表格,数据进入与破折号链接的电子表格 [Example of what it might look like]。问题是,如果在检查过程中发现错误,表格/电子邮件的副本也应发送给员工(可选地,上级的人,以便双方都知道细节,而不仅仅是填写 -在形式 - 只是选项)。由于数据的敏感性,我不能使用任何可用的 GForms 插件。审核员没有对 Forms/Dashes 的编辑权限,并且通过电子邮件发送所有信息需要很长时间。我还创建了一个test Google Form to demonstrate what it looks like。 总而言之,我正在寻找的是一个动态脚本,它还将获取员工的公司电子邮件(主管是可选的),当审核员提交表格时,表格的电子邮件/副本也会发送给上面提到的那些。我找不到任何与 GForms 相关的内容。
我之前使用过类似的脚本,但不认为它是基于添加到电子表格 [Example] 的新行。如果无法实现这样的目标,即使电子表格输入表单/电子邮件也会非常感激(基于表单中的“EmployeeEmail”+选定列的电子邮件,如工作表中标记的那样),尽管我担心事情会出错在有很多行的文件中。我试图找到类似的东西并发现了 2 个脚本,但我不知道如何使它们成为动态的:下面的第一个只是将消息发送到给定范围内的电子邮件,它是静态的(范围)。
谢谢!看起来不错,但我有 2 个问题。 编辑:,它总是需要那个虚拟电子邮件('xxx@xxx.xxx'”,这意味着我(或其他人)会收到数百封电子邮件。我们可以以某种方式摆脱这一行或用表单发件人电子邮件替换它(我可以用表单发件人电子邮件替换现有列(谷歌表单自动添加电子邮件)/那些已经在列 2/3 中的列?
第二件事,我如何将虚拟消息行连接到变量: var message = row.join('\n'); (目前从第 n 行添加值)
例如我们可以用例如替换文本连接吗?
// Info from specific columns
var Date = lastRowValues[n][5]; //I don’t know how to grab last value from columns, it’s probably something like variable.getLastRow() + variable.getLastColumn() + Get values
var ID = lastRowValues[n][6];
var Code= lastRowValues[n][8];
var Action = lastRowValues[n][9];
var Location = lastRowValues[n][10];
var ErrorType = lastRowValues[n][11];
然后在消息中
// var = message = “You’ve made an error. Please find the details below.” +
“\n “ +
“\n Date of Action: “ + Date +
“\n ID: “ + ID +
“\n Action Code: “ Code +
“\n Type of Action: “ + Action +
“\n Location: “ + Location +
“\n Error Type: “ + ErrorType +
其余部分(例如标题)可能保持不变。我意识到只有数字很难阅读。 Is it possible to achieve this output?这是looks like now。
【问题讨论】:
-
我必须为我糟糕的英语水平道歉。不幸的是,我无法理解
The thing is that in case of errors found during inspections, the copy of the form/email should be also sent to Employee (optionally, the person that is superior to them, so that both know the details, not only the auditor who fills-in the form – just option).。错误是什么? -
我认为它应该是链接电子表格中的脚本。它应该具有可安装的触发器“onFormSubmit()”,该触发器收集工作表上的最后一行,并在每次提交新表单时通过电子邮件发送(分别添加新行)。
-
是的,它可以是链接到电子表格的脚本。
标签: google-apps-script google-sheets spreadsheet google-forms