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

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

问题描述

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

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

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

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

e 对象是 enum json ,在解决方案

onChange 可安装触发器可用于通过工作表api进行的编辑.可以使用 .getActiveRange()调用来获取已编辑的范围.

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

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"?

EDIT: As per @TheMaster's suggestion, I wrote:

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

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

解决方案

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

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

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