问题
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