Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 发现重复值时发送电子邮件_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 发现重复值时发送电子邮件

Google apps script 发现重复值时发送电子邮件,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我有一个Google表单,由用户通过Slack表单填充(因此他们无法访问实际的表单)。用户在Slack中填充几个字段,并将其回复和电子邮件地址作为新行添加到工作表中。 我希望脚本能够检测A列中的数据是否为重复值,如果是,则从同一行向D列中的电子邮件地址发送电子邮件。 我在网上找到了一些关于如何通过谷歌应用程序脚本发送电子邮件的示例脚本,但没有找到如何检测重复值的示例脚本 感谢您的帮助 谢谢大家! function findDupRows() { const sh = SpreadsheetA

我有一个Google表单,由用户通过Slack表单填充(因此他们无法访问实际的表单)。用户在Slack中填充几个字段,并将其回复和电子邮件地址作为新行添加到工作表中。 我希望脚本能够检测A列中的数据是否为重复值,如果是,则从同一行向D列中的电子邮件地址发送电子邮件。 我在网上找到了一些关于如何通过谷歌应用程序脚本发送电子邮件的示例脚本,但没有找到如何检测重复值的示例脚本

感谢您的帮助

谢谢大家!

function findDupRows() {
  const sh = SpreadsheetApp.getActiveSheet();
  const vs = sh.getRange(1, 1, sh.getLastRow()).getValues().flat();
  const uA = [];
  const dR = [];
  vs.forEach((e, i) => {
    let idx = uA.indexOf(e);
    if (!~idx) {
      uA.push(e);
    } else {
      dR.push(i + 1);
    }
  });
  SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(dR.join(',')), 'Duplicate Rows');
}
活动工作表列1

项目1 项目2 项目3 项目4 项目5 项目6 项目7 项目8 项目9 项目10 项目1 项目2
不确定,但我不认为脚本在新表单进入时被激活。或者你有doPost(e)脚本吗?Stackoverflow不是一个要求代码的地方。你需要自己深入研究,举例说明你做了什么,并提出具体的内容问题。(查看:Javascript数组索引关闭)感谢您!我在玩这个,注意到即使没有重复的行,也会出现对话框。如何设置代码,使其仅在存在重复值时显示对话框?