简体   繁体   English

Google Script 上的触发器问题

[英]Issues with Triggers on Google Script

I have the following function which works perfectly fine when I run it manually.我有以下功能,当我手动运行它时,它工作得很好。

function LastUpdate() {
  var thisSS  = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = thisSS.getSheetByName('Roster');
  var data = Session.getActiveUser().getEmail();
  var Edit = 0;
  var time = TimeStamp();
  var Row;
  Row = findInColumn("L", data);
  Edit = checkEdits(Row);
  if (Edit == 1)
  {
    sheet.getRange(Row,20).setValue(time);
  }
}

I set up a trigger manually by going to Resources -> Triggers and selected the above Function to execute onEdit .我通过转到Resources -> Triggers手动设置触发器并选择上述函数来执行onEdit Basically, whenever a cell in the sheet is edited, I want to automatically trigger this function to execute.基本上,每当工作表中的单元格被编辑时,我想自动触发这个函数来执行。 I am not sure what the issue is !我不确定是什么问题!

Any help would be much appreciated.任何帮助将非常感激。

EDIT - I tried to do this and this also does not work编辑 - 我试图这样做,但这也不起作用

function onEdit(e)
{
LastUpdate ()
}

Why don't you use the simple onEdit trigger instead of the installed trigger?为什么不使用简单的 onEdit 触发器而不是已安装的触发器? Since you're looking for the latest edit made by the active user that might be a much easier, faster and more stable solution.由于您正在寻找活动用户所做的最新编辑,这可能是一个更简单、更快和更稳定的解决方案。

function onEdit(e){
  var range = e.range; //edited range

  range.getColumn();
  range.setValue(); 
  //etc

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google表格脚本编辑器触发器不起作用 - Google Sheets Script Editor Triggers not Working Google Apps脚本数组问题 - Google apps script array issues 在 Google Addon(Google App Script)中实现可安装触发器的正确方法 - Correct way to implement Installable Triggers in Google Addon (Google App Script) Google Apps 脚本:时间驱动触发器时区问题 - Google Apps Script: Time Driven Triggers timezone issue 如何将具有触发器和功能的脚本连接到多个Google表格? - How to Connect a Script with Triggers and Functions to Multiple Google Sheets? 为我使用脚本生成的多个Google表单嵌入onFormSubmit触发器 - Embedding onFormSubmit Triggers for multiple Google forms that I generate with Script Google Apps 脚本 - 从“编辑时”或“更改时”触发器中合并执行 - Google Apps Script - consolidate executions from "on edit" or "on change" triggers 如何在Google应用程序脚本中运行触发器而无需每次都重新认证 - How to run the triggers in Google app script without reauth each time Google Apps Script成功触发On Form Submit,但是function不会执行 - Google Apps Script successfully triggers On Form Submit, but function will not execute 在脚本问题中获取Google表单标题和值 - geting google form title and values in script issues
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM