How to copy a Google sheet and keep it's project triggers and scripts?

99封情书 提交于 2021-02-10 16:14:59

问题


I currently have a Google Sheet that I'm using as a master template. That is, I'm making a copy of this template for every request. I want to add a Google App Script (which onEdit POSTs to my server when the sheeting is completed) to my master template that will be duplicated and run for every copy of this template.

I've tried doing this from an admin account, however, the scripts don't seem to 'stick' with any of the templates. Is this possible?


回答1:


Installable triggers can be attached to any spreadsheet (respecting sharing permissions) from any project. You can add a new trigger to your master sheets project for each copy that is made. In the second example here they suggest using SpreadsheetApp.openById() you could also use SpreadsheetApp.openByURL() or the Spreadsheet returned by Spreadsheet#copy() depending on how you are duplicating your spreadsheet.



来源:https://stackoverflow.com/questions/49990035/how-to-copy-a-google-sheet-and-keep-its-project-triggers-and-scripts

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