How to get the onEdit event to to be caught in a Google Apps Script when editing a spreasheet via api?

陌路散爱 提交于 2020-01-01 15:08:55

问题


I have an apps script that captures the onEdit event when I edit a certain Google Spreadsheet cell manually, and applies various formatting changes based on the change.

However, when I edit the same cell using the Google Drive API, the script doesn't seem to run.

Is there some way to trigger an event via the api which can be caught by the apps script? Or some other solution for this?


回答1:


Publish as a web app:

it is possible to trigger Google apps script code using a URL, i.e. from the Google apps script editor Menu->publish->Publish as web app. You can then pass the id of the cell as a parameter to the "web app". and have the web app call the onEdit.

I suspect the "google-spreadsheet-api" has no way to do this, as even basic things such as "insert a row in the middle of a sheet", don't exist.



来源:https://stackoverflow.com/questions/14775760/how-to-get-the-onedit-event-to-to-be-caught-in-a-google-apps-script-when-editing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!