[英]How to get installable trigger to sense event
I created an installable trigger in a standalone script.我在独立脚本中创建了一个可安装的触发器。 When I change something in the target spreadsheet, nothing happens.
当我更改目标电子表格中的某些内容时,什么也没有发生。 I don't get to a brekpoint in
onEdit
.我没有到达
onEdit
的断点。 So how do I set up the trigger and onEdit
to detect Edits?那么如何设置触发器和
onEdit
来检测编辑?
ScriptApp.newTrigger('myOnEdit'){
.forSpreadsheet('1wfcYwChzLmbqxoXoSZUrXgZJIVbtEyNUIpfxmJihAcY')
.onEdit()
.create();
)
function onEdit(e){
// Set a comment on the edited cell to indicate when it was changed.
var range = e.range;
var ct = e.changeType
var ov=e.oldValue
var nv =e.value
var sc=e.triggerUid
range.setNote('Last modified: ' + new Date());
}
onEdit
is a reserved function name to be used for on edit simple trigger. onEdit
是保留的 function 名称,用于编辑简单触发器。 It should not be used for functions that will be called by an installable triggers as this could cause undesired effects as executing the function twice by a single event.它不应用于将由可安装触发器调用的函数,因为这可能会导致不希望的效果,因为通过单个事件执行 function 两次。
The installable trigger is being created to call a function named myOnEdit
.正在创建可安装触发器以调用名为 myOnEdit 的
myOnEdit
。 In order to make it works your script should have a function named myOnEdit
.为了使它工作,你的脚本应该有一个名为 myOnEdit 的
myOnEdit
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.