无法在一秒钟内多次调用Google App Script onEdit功能 [英] Failure of calling Google App Script onEdit function many times in a second

查看:108
本文介绍了无法在一秒钟内多次调用Google App Script onEdit功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力应对Google Apps脚本的onEdit功能的奇怪行为。

I have been struggling with a strange behavior of onEdit function of Google Apps Script.

根据我的理解,每次编辑单元格时都会触发此onEdit事件。当我每1秒钟像一个单元格慢慢编辑一个单元格时没有问题。肯定会触发所有事件。

To my understanding, this onEdit event is fired every time a cell is edited. It is no problem when I edit a cell slowly like one cell for every 1 second. All events are fired for sure.

然而,当我在一秒钟内编辑一些单元格时,很快就会解雇其中一些单元格。因此,即使我非常快速地编辑单元格,我也希望确保onEdit事件被触发。以下是我的代码,我错过了什么?

However, when I edit a few cells in a second very quickly, some of them aren't fired. So I want to make sure onEdit event is fired even when I edit cells very quickly. Below are my code, am I missing something?

我这整天都在调试......请帮我解决这个问题。

I have been debugging for this whole day... Please help me out with this issue.

function onEdit(e){
  var as = SpreadsheetApp.getActiveSheet();
  var r = e.source.getActiveRange();
  var edditRow = r.getRow();
  console.log(edditRow);
  as.getRange(edditRow, 2).setValue('edited');
}


推荐答案

这是一个已知的限制onEdit。

This is a known limitation of onEdit.

来自评论来自Google员工的Eric Koleda 在新表格中,一次只能排队两个onEdit触发事件

From a comment by Eric Koleda, a Googler, to Only two onEdit trigger events can be queued at a time in New Sheets


您必须假设onEdit触发器是尽力而为,但可能无法捕获对电子表格所做的所有编辑。

You'll have to assume that onEdit triggers are best-effort, but may not catch all edits done to the spreadsheet.

这篇关于无法在一秒钟内多次调用Google App Script onEdit功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆