dyl*_*jha 7 google-docs google-apps-script
Google Apps 有一些简单的触发器:https ://developers.google.com/apps-script/guides/triggers/
其中之一是 onEdit。如文档所述,onEdit 会针对 Google Spreadsheets 触发,但不会针对 Google Docs 触发。
是否有一种干净的方法来检测用户何时更改了文档,并在发生这种情况时运行脚本?
这不是一个完整的答案,但这可能(不确定)根据您的实际要求对您有所帮助。您可以拥有这样的函数,然后使用安装的触发器,您可以每分钟调用此函数来轮询文档并检查是否有人对其进行了编辑。
function isEdited()
{
var MyDoc = DocumentApp.getActiveDocument().getBody();
var Text = MyDoc.editAsText().getText();
var DocLen= Text.length;
if(DocLen!= PropertiesService.getDocumentProperties().getProperty('DocLen'))
{
CallYourFunction();
PropertiesService.getDocumentProperties().setProperty('DocLen', DocLen)
}
}
Run Code Online (Sandbox Code Playgroud)
您的服务允许 60 秒延迟吗?60 秒是此处可能发生的最大延迟。
| 归档时间: |
|
| 查看次数: |
2684 次 |
| 最近记录: |