GAS“编辑中"从 API 编辑时触发器未运行 [英] GAS "On edit" trigger not running when edited from API

查看:19
本文介绍了GAS“编辑中"从 API 编辑时触发器未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人遇到过这个问题并想到了一个并不可怕的解决方法.

I was wondering if someone encountered this issue and thought of a workaround that isn't awful.

我在 Google 电子表格上有一个触发器,该触发器配置为编辑时",如果编辑手动(或通过公式)从电子表格本身进行,它可以正常工作.但是,如果我从 Sheets API v4 外部修改单元格,单元格已更改但功能未触发.是我遗漏了什么,还是 Google 根本不支持在外部"发生变化时触发?

I have a trigger on Google Spreadsheets that is configured "on edit", and it works fine if the edit occurs manually (or via formula) from within the spreadsheet itself. However if I modify a cell externally from the Sheets API v4, the cell is changed but the function isn't triggered. Am I missing something, or Google simply doesn't support triggering when change comes from "outside"?

根据@TheMaster 的建议,我写道:

As per @TheMaster's suggestion, I wrote:

function test_on_change(e){
  console.log("Changed");
  console.log(SpreadsheetApp.getActiveRange().getA1Notation());
}

e 对象是 此处.

The e object is json of the enum that is described here.

推荐答案

onChange 可安装触发器适用于从 sheet api 所做的编辑.可以使用 .getActiveRange() 调用获取编辑的范围.

onChange installable trigger works with edits made from sheets api. It is possible to get the edited range using .getActiveRange() calls.

这篇关于GAS“编辑中"从 API 编辑时触发器未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆