[英]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.