Javascript 针对特定列中新输入的值触发电子邮件响应

Javascript 针对特定列中新输入的值触发电子邮件响应,javascript,google-apps-script,google-sheets,Javascript,Google Apps Script,Google Sheets,我有一个看起来很像这样的电子表格: onMyEdit(e) { console.log(JSON.stringify(e));//look in executions to see the structure and available values in the event object. They can save your function a lot of time. const sh=e.range.getSheet(); if(sh.getName()!='Your S

我有一个看起来很像这样的电子表格:

onMyEdit(e) {
  console.log(JSON.stringify(e));//look in executions to see the structure and available values in the event object.  They can save your function a lot of time.
  const sh=e.range.getSheet();
  if(sh.getName()!='Your Sheet Name')return;
  if(e.range.columnStart==8 && e.range.rowStart>3 && e.value!='') {
    //write you email function here.
    //since sending an email requires permission then this needs to be an installable trigger
    //And keep in mind onedit triggers will time out after 30 seconds.
  }
}

这是一个帮助学生计划课堂作业的电子表格。我在末尾创建了一个列,需要帮助,这是一个值列表,这些值是它们的亲属的名字。让我们假设这个列表是
[Alice,Bob,Trent]
。我想编写一个电子表格函数,在列中输入所需的
帮助值后,将向特定人员发送一封电子邮件,其中包含以下消息:

“Eve需要您帮助完成“+行[1]+”类的作业。该作业应在“+行[5]+”到期,并且是“+行[3]”优先项。

因此,
第[1]行
将是
,第[5]行是到期日,第[3]行是优先级。如果这不明显的话。我只见过发送电子邮件和其他东西的脚本,但它似乎是你必须手动运行的东西。当然,我可以让学生这样做——但是有没有办法让它自动化呢


谢谢。

试试这样:

onMyEdit(e) {
  console.log(JSON.stringify(e));//look in executions to see the structure and available values in the event object.  They can save your function a lot of time.
  const sh=e.range.getSheet();
  if(sh.getName()!='Your Sheet Name')return;
  if(e.range.columnStart==8 && e.range.rowStart>3 && e.value!='') {
    //write you email function here.
    //since sending an email requires permission then this needs to be an installable trigger
    //And keep in mind onedit triggers will time out after 30 seconds.
  }
}


试试这样的方法:

onMyEdit(e) {
  console.log(JSON.stringify(e));//look in executions to see the structure and available values in the event object.  They can save your function a lot of time.
  const sh=e.range.getSheet();
  if(sh.getName()!='Your Sheet Name')return;
  if(e.range.columnStart==8 && e.range.rowStart>3 && e.value!='') {
    //write you email function here.
    //since sending an email requires permission then this needs to be an installable trigger
    //And keep in mind onedit triggers will time out after 30 seconds.
  }
}


尝试使用可安装的onEdit触发器。@Cooper像这样对我说话是我第一次使用google电子表格的javascript,因为猜猜使用可安装的onEdit触发器有什么用。@Cooper像这样对我说话是我第一次使用google电子表格的javascript,因为猜猜是什么谢谢你,我会尽快回复你并接受,如果有效的话。非常感谢你,我会尽快回复你并接受。谢谢你,伙计