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.
The template document is owned by my GAE web app. Creating a new document via the web app uses the following process:
- Make a copy of the template in the web app's service account.
- Update the document's media_body with user-supplied content;
- Insert permissions to set the user as the document owner;
- Delete the permissions associated with the web app service account so that the document is private to the user that created it.
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'.
Why doesn't onOpen() execute in the copied, private document?
onOpendoes not run? Can you run some additional tests like adding this service account as a collaborator on docs whereonOpenruns fine? - Arun NagarajanonOpen()does not run after the service account is REMOVED as a collaborator. - rphv