Delayed Execution on Edit with Google Apps Script

六眼飞鱼酱① 提交于 2019-12-06 08:04:34

Firstly, I would say you should look at Google Sheets' conditional formatting (Format > Conditional formatting menu item in Sheets) -- you may be able to do much of what you need without involving Apps Script at all.

Failing that, you can set up a regular time-based trigger to check for edits and change the backgrounds appropriately. You can support this trigger with a separate onEdit() trigger to record what has changed internally. The flow goes like this:

  1. A change is made and onEdit() triggers
  2. The onEdit() trigger only records the changed cell locations to a local variable or Cache
  3. A time-based trigger fires every minute/hour/whenever
  4. The time-based trigger checks the cache for edited cells, alters their backgrounds, then clears them from the cache

That said, depending on your workflow this approach may not be much better than simply using a time trigger to change the cells directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!