简体   繁体   English

如何让我的可安装触发器运行一次而不是两次?

[英]How Do I Get My Installable Trigger to Run Once and Not Twice?

I have a simple onEdit script that can run longer than 30 seconds, depending on what I am doing on my spreadsheet and in some cases, I need this to happen.我有一个简单的 onEdit 脚本,它可以运行超过 30 秒,这取决于我在电子表格上所做的事情,在某些情况下,我需要这样做。

I understand, if I do not use an installable trigger in this case, that the simple onedit script will time out.我明白,如果我在这种情况下不使用可安装的触发器,那么简单的 onedit 脚本就会超时。 So I now have a simple onEdit trigger and installable onEdit trigger that can run at the same time.所以我现在有一个简单的 onEdit 触发器和可以同时运行的可安装的 onEdit 触发器。

But here is my problem.但这是我的问题。 I mentioned that I need my script to run longer than 30 seconds sometimes.我提到我有时需要我的脚本运行超过 30 秒。 But if I use an installable trigger, in conjunction with the simple trigger, the onEdit function will begin to cause the changes that do not require 30 seconds of run time to fire twice and I don't want this to happen.但是如果我使用可安装的触发器,结合简单的触发器,onEdit 函数将开始导致不需要 30 秒运行时间的更改触发两次,我不希望这种情况发生。

Incidentally, if I do not use an installable trigger and only use the simple trigger, the changes that do not require 30 seconds of run time fire once and do as I need.顺便说一句,如果我不使用可安装的触发器而只使用简单的触发器,则不需要 30 秒运行时间的更改会触发一次并根据需要执行。 But then the changes that require 30 seconds of run time times out, incompleting the tasks that I need done.但随后需要 30 秒运行时间的更改超时,无法完成我需要完成的任务。

So how do I get the installable trigger to run the changes needed under 30 seconds once, while still giving me the ability to run changes longer than 30 seconds when needed?那么如何让可安装的触发器在 30 秒内运行一次所需的更改,同时仍然让我能够在需要时运行超过 30 秒的更改?

You are right about that the simple triggers cannot run for longer than 30 seconds, while the installable ones do.您是对的,简单触发器的运行时间不能超过 30 秒,而可安装的触发器则可以。

So, why do you not user ONLY the installable trigger without the simple one.那么,为什么不只使用可安装的触发器而不使用简单的触发器 You can bind it to any desired function, it doesn't need to be called onEdit() .您可以将其绑定到任何所需的函数,不需要调用onEdit()

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM