如何使用推送通知跟踪Google表格中的更改?

发布于 2025-02-06 21:29:28 字数 396 浏览 2 评论 0原文

如何使用推送通知跟踪Google表格中的更改? 我的Web应用程序应收到有关更改A的通知,并写入BENG B,

我必须跟踪A e纸的更改,如果更改将数据写入表B,

我使用了此指南

我尚未找到如何跟踪特定表格,而不是

成功获得的 整个文档当Google表文档更改

我的问题时,通知是我在同一文档中阅读和写作时,当我的应用程序在表A上收到更改消息并将数据写入表B时,我再次收到一个更改通知,一切都开始了(无限环形)

How can I track changes to a sheet in Google sheets using Push notifications?
My web application should receive a notification about a change in sheet A and write to sheet B

I have to track changes in sheet A and in case of changes write data to sheet B

I used this guide

I have not found how to track a specific sheet and not the entire document

I am successfully getting a notification when a google sheets document changes

My problem is that I am reading and writing in the same document, when my application receives a change message on sheet A and writes data to sheet B, I get a change notification again and everything starts over (infinite loop)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪荡不羁 2025-02-13 21:29:28

如果用户手动编辑您的工作表,则可以创建可安装触发器

function pushNotification(e) {

  const payload = {
    cell: e.range.getA1Notation,
    old_value: e.oldValue,
    new_value: e.value,
    editor: e.user
  }

  const yourWebAppUrl = "https://something.com/"

  // I don't know how your web app receives information
  // so edit the request to match what you need

  const response = UrlFetchApp.fetch(yourWebAppUrl, {
    method: 'get',
    contentType: 'application/json',
    payload: JSON.stringify(payload)
  })
}

如果您的工作表不是手动编辑的,而是通过脚本:

// you can't

If your sheet is edited manually by a user you can create an installable trigger:

function pushNotification(e) {

  const payload = {
    cell: e.range.getA1Notation,
    old_value: e.oldValue,
    new_value: e.value,
    editor: e.user
  }

  const yourWebAppUrl = "https://something.com/"

  // I don't know how your web app receives information
  // so edit the request to match what you need

  const response = UrlFetchApp.fetch(yourWebAppUrl, {
    method: 'get',
    contentType: 'application/json',
    payload: JSON.stringify(payload)
  })
}

If your sheet is edited not manually, but by script:

// you can't
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文