Google文件:onOpen()不会在复制的文件+指令码中执行 [英] Google Doc: onOpen() doesn't execute in copied document+script

查看:52
本文介绍了Google文件:onOpen()不会在复制的文件+指令码中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有关联的容器绑定脚本的模板文档.该脚本不需要身份验证-只需在Google Docs UI中创建一个自定义菜单即可.

I have a template document with an associated container-bound script. The script does not require authentication - it simply creates a custom menu in the Google Docs UI.

模板文档归我的GAE网络应用所有.通过Web应用程序创建新文档的过程如下:

The template document is owned by my GAE web app. Creating a new document via the web app uses the following process:

  1. 在网络应用的服务帐户中复制模板.
  2. 使用用户提供的内容更新文档的media_body;
  3. 插入权限以将用户设置为文档所有者;
  4. 删除与Web应用程序服务帐户关联的权限,以使该文档对于创建它的用户而言是私有的.

除了在脚本中执行onOpen()函数外,此过程按预期工作.脚本已与文档一起成功复制,并且onOpen()可以手动运行(使用脚本管理器"),但是在打开文档时不会自动执行.删除第4步可以解决此问题,但这会使文档比私人文档少".

This process works as expected EXCEPT for the execution of the onOpen() function in the script. The script is successfully copied along with the document, and onOpen() can be run manually (using the 'Script Manager'), but it doesn't execute automatically when the document is opened. Removing step 4 solves the problem, but this makes the document 'less than private'.

为什么onOpen()在复制的私有文档中不执行?

Why doesn't onOpen() execute in the copied, private document?

推荐答案

这是因为原始的onOpen使用原始的所有者权限运行.当您从权限中删除该用户时,它将无法使用那些保存的凭据. 或者不要删除它,或者最好不要更改所有权,而只是与用户共享.因为您将拥有创建的所有系统文件,所以这也将给您带来更多的控制权.

Its because the original onOpen runs with the original owner permissions. When you remove that user from the permissions, it wont be able to use those saved credentials. either dont remove it, or better yet dont change ownership just share it with the user. That will also give you more control since you will own all the system files created.

这篇关于Google文件:onOpen()不会在复制的文件+指令码中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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