How to write a bound script for a programmatically

2019-07-08 11:14发布

I have a google form that programmatically creates registration forms (with associated spreadsheet) for events. These Forms will collect emails and I'd like to send a notification email to registrants who use these programmatically created forms - without having to go manually into each one of these forms/spreadsheets to insert the script that would achieve that. In other words is there a way of creating a bound script for a programmatically created google form/sheet?

1条回答
太酷不给撩
2楼-- · 2019-07-08 11:33

Apps Script includes special APIs to let you programmatically create, read, and edit Google Sheets. Apps Script can interact with Google Sheets in two broad ways: any script can create or modify a spreadsheet if the script's user has appropriate permissions for the spreadsheet, and a script can also be bound to a spreadsheet, which gives the script special abilities to alter the user interface or respond when the spreadsheet is opened. To create a bound script, select Tools > Script editor from within Google Sheets.

Scripts that are bound to a Google Sheets file can use simple triggers like the functions onOpen() and onEdit() to respond automatically when a user who has edit access to the spreadsheet opens or edits the spreadsheet.

To make it programmatically i think you can use the installable trigger. It let Google Sheets run a function automatically when a certain event occurs, such as opening a document. Installable triggers, however, offer more flexibility than simple triggers they can call services that require authorization and offer several additional types of events including time-driven (clock) triggers,they can also be controlled programmatically. For both simple and installable triggers, Apps Script passes the triggered function an event object that contains information about the context in which the event occurred.

Check this page for more information about installable triggers

Also Apps Script includes special APIs to let you programmatically create, read, and edit Google Apps files. To build most add-ons, you'll need to be familiar with at least one of these services.

  • Spreedsheet Service
  • Document Service
  • Forms Service

NOTE: Only users who have permission to edit a spreadsheet, document, or form can run its bound script. Collaborators who have only view access cannot open the script editor, although if they make a copy of the parent file, they become the owner of the copy and will be able to see and run a copy of the script.

查看更多
登录 后发表回答