插入新行时在谷歌电子表格上触发脚本 [英] Trigger script on google spreadsheet when a new row is inserted
问题描述
我正在谷歌电子表格上运行一个脚本,它应该由来自 Zapier (www.zapier.com) 的 zap 的 onChange() 事件(当在电子表格中插入新行时)触发.我可以在电子表格中看到正在创建的新信息,但未触发触发器.我已经用 onEdit() 事件进行了测试,但它不起作用.它不应该是基于时间的触发器.
I'm running a script on a google spreadsheet, that should be triggered by the onChange() event (when a new row is inserted in the spreadsheet) by a zap from Zapier (www.zapier.com). I can see the new info being created in the spreadsheet, but the trigger is not triggered. I already tested with the onEdit() event, but it's not working. It should not be a time-based trigger.
有什么建议吗?
推荐答案
我从外部 api(在我的例子中是 IFTTT)获取数据,并通过使用下面的函数,我触发了一个 url 获取函数来发送数据(最后一行)到另一个外部 api(我自己的网站).完美运行.
I'm getting data from external api (in my case IFTTT) and by using below function, I'm triggering a url fetch function to send data (the last Row) to another external api ( my own website). Working perfectly.
function onChange(e) {
var ss = SpreadsheetApp.getActive();
ScriptApp.newTrigger('name of the function you need to trigger')
.forSpreadsheet(ss)
.onChange()
.create();
}
这篇关于插入新行时在谷歌电子表格上触发脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!