[英]Google Apps Scrip onEdit()-function gives "exceeded maximum execution time"
I have a script that has been working smoothly for the last 3 weeks in Apps Script, but since a few days ago it stopped functioning.我有一个脚本在过去 3 周内一直在 Apps Script 中顺利运行,但从几天前开始它就停止运行了。 Looking at the executions there seems to be quite many running at the same time and many that also has "Timed out".查看执行情况似乎有很多同时运行,而且许多也“超时”。 Error message says " exceeded maximum execution time ".错误消息说“超出最大执行时间”。
This is the script:这是脚本:
function onEdit(e) {
const sh = e.range.getSheet();
if (sh.getName() == 'B2B_LeadList' && e.range.columnStart === 22 && e.range.rowStart > 1 && e.value === 'STARTED') {
sh.getRange(e.range.rowStart, 23).setValue(new Date());
}
if (sh.getName() == 'B2B_LeadList' && e.range.columnStart == 35 && e.value == 'YES') {
var tsh = e.source.getSheetByName('B2B_Archive');
var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
sh.getRange(e.range.rowStart, 36).setValue(new Date());
sh.getRange(e.range.rowStart, 1, 1, sh.getLastColumn()).moveTo(trg);
sh.deleteRow(e.range.rowStart);
}}
Anyone got any recommendations on how I can tweak the script?有人对我如何调整脚本有任何建议吗? or any work around to get the script running again?或者有什么办法让脚本再次运行? Thanks!谢谢!
Tweaking the script调整脚本
A single execution of Apps script can last no longer than 6 minutes and you're probably hitting this limit. Apps 脚本的单次执行持续时间不会超过 6 分钟,您可能已达到此限制。 https://www.steegle.com/google-products/google-apps-script-faq https://www.steegle.com/google-products/google-apps-script-faq
You can avoid it by splitting your script in to two.您可以通过将脚本分成两部分来避免它。 like Script 1 is doing 1-500 rows and script 2 is doing 501-1000 rows.比如脚本 1 正在执行 1-500 行,而脚本 2 正在执行 501-1000 行。
Second way is to try to optimize the script第二种方法是尝试优化脚本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.