admin管理员组文章数量:1391934
I have been struggling with a strange behavior of onEdit function of Google Apps Script.
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.
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');
}
I have been struggling with a strange behavior of onEdit function of Google Apps Script.
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.
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');
}
Share
Improve this question
edited Oct 15, 2018 at 16:54
Wicket
38.8k9 gold badges80 silver badges195 bronze badges
asked Oct 15, 2018 at 7:08
stevesteve
16713 bronze badges
4
-
Try
LockService
? – TheMaster Commented Oct 15, 2018 at 9:32 - I added LockService but it didn't work... – steve Commented Oct 15, 2018 at 10:55
- Edit to show 1. modified code 2. Script execution log(view>executions) with relevant explanations and error logs – TheMaster Commented Oct 15, 2018 at 11:04
- @steve you seem to be right. I did it slightly different and simply typed a character and return several times in a row quickly. The cursor advances to the next row and again the next row but seems to skip every other setValue("edited"). {e.range.offset(0,1,1,1).setValue("edited");} – TheWizEd Commented Oct 15, 2018 at 14:18
1 Answer
Reset to default 9This is a known limitation of onEdit.
From a ment by Eric Koleda, a Googler, to Only two onEdit trigger events can be queued at a time in New Sheets
You'll have to assume that onEdit triggers are best-effort, but may not catch all edits done to the spreadsheet.
本文标签: javascriptFailure of calling Google App Script onEdit function many times in a secondStack Overflow
版权声明:本文标题:javascript - Failure of calling Google App Script onEdit function many times in a second - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744723464a2621834.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论