Google Apps Script Triggers Simple Triggers automation and more

Google Apps Script Triggers Simple Triggers automation and more

Google Apps Script Triggers Simple Triggers automation and more

Google Apps Script Triggers for Automation

Triggers allow you to run a function automatically within Apps Script. There are simple triggers that are built in and use custom functions in order to start and invoke the function. Within the event object of each event, the triggered function contains an event object that has information about the context in which the event occurred. Some commonly used simple triggers are onOpen() which runs when the spreadsheet, document, is opened. There is onEdit() that runs when the user changes a value in a spreadsheet. Also for web apps doGet() and doPost() are simple triggers that get invoked when the user visits the web application on either method.

Simple triggers must be in a bound script in order to run the application triggers, they also fire automatically without asking for user permissions. They will not run if the file is opened in read only mode. They are also limited in some services that would require authorization. They cannot run for longer than 30 seconds. Simple triggers are subject to Apps Script trigger quota limits.

Installable triggers provide more flexibility for users, they let Apps Script run a function automatically and can also run services that require authorization. Just like the simple triggers the event object is included in each event, that contains information about the context of the event. Installable triggers always run under the account of the person who created them. Installable triggers are subject to Apps Script trigger quota limits.

You can create installable triggers with Apps Script code.

Create a function that you can add to run automatically with a time based trigger.

  1. Create a function that opens a spreadsheet, and generates a random value that can get added to the sheet.
  2. Create the trigger either manually or with code to run every 1 minute.
  3. Close the application and reopen after several minutes. Confirm the function ran and updated your Spreadsheet.
  4. Open the Triggers menu option, and delete the trigger.

Leave a Comment