google-apps-script - Google App-Script save global Spreadsheet scirpt
问题描述
So I was using spreadsheets for a Game to ease things up for me and be organized about it. I am using sheets that contain information on columns A:D and a random amount of rows.
Column D is a data validation checkbox.
After some time I started removing checked lines manually because I didn't need them anymore and I thought maybe I'd see if I can automate the deletion in google and found out about AppScripts. My script works as Follows ->
I've written an Event based trigger that reacts to sheet manipulation. I then check if the checkbox was ticked and if so remove the row.
Here's my problem:
After I removed all rows of the sheet I wanted to delete the entire document. Next time I'm playing I'd import a new csv file with completely different data into the sheet and want to use the same AppScript again on that new document. The thing is I seem to be unable to create a script that is available to all SpreadSheet documents. The AppScript seems to be only existent in that one document. I found out that I can have independent AppScript projects but if I try to add a trigger to those I can only use timed triggers and not event based ones.
The questions would be:
- Can I somehow save an AppScript project that is independet from a specific Google Sheets Document so I can use that (and an Event based trigger) in any new document that I might create?
Thank you for reading ;)
解决方案
您可以创建一个独立的脚本,并从中为所有需要它们的电子表格创建可安装的触发器。请记住,除非您使用 Run > Test 作为附加功能,否则简单的触发器在独立脚本中不起作用。
注意:https://script.google.com上脚本的触发器页面将列出所有触发器,但不会显示针对哪个电子表格执行的触发器操作,因此您可能会发现记录电子表格名称/网址以使其更容易对触发器进行故障排除。
资源
推荐阅读
- javascript - 堆栈跟踪中的这些额外数字 a:bc 是什么意思?
- java - Java 泛型函数返回声明
- c# - PopUp 是否适合显示两个图像按钮以便让用户在两个选项之间进行选择?
- android - 应用程序进入后台后,Android 不会保持静态字段处于活动状态
- android - 来自位图源的图像的 LazyColumn 闪烁/闪烁
- python - 如何在 scipy.stft 中指定参数以重现已发布的分析
- reactjs - Draft.js 出现错误:堆栈帧已折叠
- php - CakePHP:登录 2 个表
- logstash - Logstash - 删除包含 kv 值的日志
- python - 我如何访问(操作)音频位(二进制)我在哪里可以了解它?