当项目添加并发布时,我想了解GAS的SpreadsheetTriggerBuilder [英] I want to know about SpreadsheetTriggerBuilder of GAS when the project is add-on and published
问题描述
我正在开发google-sheeets插件.
I am developing google-sheeets add-on.
我想创建函数来创建与各个电子表格相关联的触发器. 我认为GAS SpreadSheetTriggerBuilder 实现了此功能,但是我不知道添加和发布项目时的行为.
I want to create functions that create triggers associated to individual spreadsheets. I think that GAS SpreadSheetTriggerBuilder realize this function, but I don't know the behavior when the project is add-on and published.
附加用户添加到每个电子表格中的触发器将被共享?
Trigers that the add-on users add to each spreadsheets will be shared??
例如, A和B将加载项安装到自己的电子表格中. 带有附件的添加Triger,然后B将能够使用A添加到工作表的Triger?
For example, A and B install the add-on to their own spreadsheet. A add Triger with the add-on, then B will be able to use the Triger that A add to the sheet??
推荐答案
When building a trigger with the SpreadSheetTriggerBuilder, an installable trigger will be created
This means:
- 触发器在创建它的人的授权下运行-并将代表安装触发器的人执行绑定功能
- 换句话说-如果您的附件安装了
onEdit
触发器-该触发器将为所有编辑电子表格但被授权为安装触发器的人的用户触发
- 但是,当您构建触发器时,它仅适用于您需要定义的特定电子表格,例如
- The trigger runs under the authorization of the person who created it - and will execute the bound function on behalf of the person who installed the trigger
- In other words - if your Add-on installs an
onEdit
trigger - this trigger will fire for all users who edit the spreadsheet, but authorized as the person who installed the trigger
- However, when you build a trigger it applies only to a specific spreadsheet that you need to define,e.g.
var sheet = SpreadsheetApp.getActive();
ScriptApp.newTrigger("myFunction")
.forSpreadsheet(sheet)
.onEdit()
.create();
- 也就是说,如果用户A在打开电子表格A时创建触发器A,而用户B在打开电子表格B时创建触发器A-这些触发器将不会进行推断.触发器A仅在编辑电子表格A时触发,触发器B仅在编辑电子表格B时触发.
这篇关于当项目添加并发布时,我想了解GAS的SpreadsheetTriggerBuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
onEdit
触发器-该触发器将为所有编辑电子表格但被授权为安装触发器的人的用户触发onEdit
trigger - this trigger will fire for all users who edit the spreadsheet, but authorized as the person who installed the triggervar sheet = SpreadsheetApp.getActive();
ScriptApp.newTrigger("myFunction")
.forSpreadsheet(sheet)
.onEdit()
.create();
这篇关于当项目添加并发布时,我想了解GAS的SpreadsheetTriggerBuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!