Zapier添加行时未触发Google Apps脚本onEdit触发器 [英] Google Apps Script onEdit Trigger Not Firing When Zapier Adds A Row

查看:62
本文介绍了Zapier添加行时未触发Google Apps脚本onEdit触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了我的Google App脚本触发器无法正常启动的问题.我的Google Spreadsheet有两张纸.一个保存库存,另一个保存订单数量.我与Zapier有联系,因此当放置新订单时,它将在订单"表中添加新行.我希望我的主要功能在下订单时运行,并将新行添加到订单"表中.目前,如果我进入工作表并手动编辑信息,它将触发,但是当Zapier自动添加一行时,它将不会触发.

I am experiencing an issue with my Google App Script trigger not firing appropriately. My google Spreadsheet has two sheets. One that holds inventory and the other that tracks order quantity. I have a hookup with Zapier, so when a new order is placed it adds a new row to the 'Orders' sheet. I want my main function to run whenever an order is placed and a new row is added to the 'Orders' sheet. Currently, it will fire if I go into the sheet and manually edit information but it will not fire when Zapier adds a row automatically.

这是代码:

function onEdit(e) {
    var activeSheet = e.source.getActiveSheet();
    var range = e.range;
    if (activeSheet.getName() !== 'Orders') return;
    var productOrdered = orderID();
    var amountOrdered = orderQuantity();
    var productList = productArrayFunction();
    var productMatched = findMatchingProductId(productList,productOrdered);
    var rowNumber = lookup(productOrdered);
    var subtractInventory = subract(rowNumber,amountOrdered);
}

我可能会以错误的方式进行操作,但是我觉得这应该可以按预期进行.我不是编码专家,因此不胜感激.

I might be going about this the wrong way but I feel like this should work as intended. I am not a coding expert so any guidance would be greatly appreciated.

推荐答案

Zapier利用Google表格API更新您的Google表格.但是,onEdit事件需要用户直接与工作表交互;这意味着它将不会检测到API所做的更新.

Zapier leverages the Google Sheets API to update your google sheet. However the onEdit event requires a user to directly interact with the sheet; that means it won't detect updates made by the API.

我假设您使用Zapier作为第三方API/服务和Google表格之间的中介.您可能可以直接使用Google Apps脚本连接到该API/服务.这将使您可以更好地控制数据如何流到表单以及脚本如何管理和/或对任何更改做出反应(甚至可以消除Zapier订阅).

I assume that you are using Zapier as an intermediary between a 3rd party API/service and Google Sheets. You can probably connect to that API/service directly using Google Apps Script. This would allow you to have more control over how data flows to your sheet and how your scripts manages and/or reacts to any changes (you might even be able to eliminate your Zapier subscription).

这篇关于Zapier添加行时未触发Google Apps脚本onEdit触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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