How to get all form triggers (not just for the current script)?

I did the following:

  1. Created a Google Form (e.g. form ID = ABC)
  2. Created a Google Sheet (let's call it sheet1)

In sheet1's script editor, installed a trigger to my form with code such as the following:

var form = FormApp.openById("ABC");
ScriptApp.newTrigger("testFunctionSheet1").forForm(form).onFormSubmit().create();

When I call the following, I see my trigger was installed properly:

ScriptApp.getUserTriggers(form);

Everything is great. I can execute code whenever a Google Form is submitted.

Problem is, later on I go ahead and create a new Google Sheet (let's call it sheet2), which has similar code:

ScriptApp.newTrigger("testFunctionSheet2").forForm(form).onFormSubmit().create();

To be safe, though, I attempt to remove all the previous triggers from all my old scripts (i.e. sheet1). However, when I run:

ScriptApp.getUserTriggers(form);

... it returns one result (testFunctionSheet2) instead of returning both testFunctionSheet1 and testFunctionSheet2. Turns out it only returns triggers that are executed by the current script!

This is problematic because it may mean I accidentally have many scripts that are all executing upon a form's submission. If I never wrote down which scripts execute for which forms, I would have no idea what exactly is run from each submission. Some of those scripts may either do the same thing (which is a waste of CPU cycles at best, or will interfere with each other at worst), or they may do completely different things and potentially clash with each other.

I want a simple way to find all script triggers that will be executed on form submission. Something like if the function actually behaved as I would expect...

I.e. ScriptApp.getUserTriggers(form) should return something like:

  • sheet1: testFunctionSheet1
  • sheet2: testFunctionSheet2

This way I can easily tell which scripts will be executed upon form submission and can manually remove the old ones, to ensure nothing clashes.

Is there a way to find out which triggers will execute across all my scripts upon form submission?


Update: The documentation for getUserTriggers() clarifies that it will never return triggers for different scripts:

Gets all installable triggers owned by this user in the given form, for this script or add-on only. This method cannot be used to see the triggers attached to other scripts.

How, then, would I know all triggers associated with a given Google Form? Note: this doesn't necessarily have to be a programmatic solution. If there was a UI element in Forms that gave me this information, that would suffice too.

There doesn't seem to be a way to do this, but there are some workarounds that can make things a bit more organized:

  1. Instead of installing the form trigger on a Sheet, install it on the Form. If you get into this habit, you can easily tell if there are scripts installed because the first place you'd check is in the Form's script. Simply run the get all triggers command as you tried above, and it'll work.

  2. Instead of installing the form trigger on a Form, set the form to submit its responses to the Sheet, and use the onFormSubmit() method in SpreadsheetTriggerBuilder. To find out which trigger is associated with a form becomes as simple as opening the form, then going to its destination, and then looking if that script has a trigger for the form.

  3. Hide the trigger script names in some property on the Form that you don't plan on showing to the user (e.g. customClosedFormMessage). Set it to something like This script has an active trigger associated with sheet1. You can create a helper function that before installing a trigger, it ensures that that text doesn't exist there (if you want to limit to 1 trigger per form, for example).

Installable trigger onFormSubmit in Sheets Template not starting , I had to run the trigger function in the copy to set the trigger to that new project. marked this as an answer getSheetByName("Form Responses 1"); The only way it seems to work is if I go into current project triggers All Replies (5) installed to trigger to the form, where it should have the spreadsheet. While this does create a SQL script for the tables and constraints, it does not generate SQL for the triggers. I also understand that I can right click on each trigger in the database and select the Generate SQL Script option but, there is currently 46 tables under audit (For Insert, Update, and Delete).

Go to https://script.google.com/home/triggers?trigger_type=3&document_id=ABC

That should give a list of all triggers from form with id ABC. You can clear filters there and add new filters.

How to Integrate Google Apps Script & Trigger with an AppSheet App, Any Google Apps Script project, can be developed in 2 platforms or editors: [ STRUCTURE AND THE APP BUILD] I will try to explain briefly but as An installable form submit trigger runs when a user responds to a form. Trigger Not getting executed when a new row is added through AppSheet form. For both types of triggers, Apps Script passes the triggered function an event object that contains information about the context in which the event occurred. Note: For information on how to use

As the OP already mentioned on the question, the documentation says that a script can't get triggers created by other scripts.

If you are the only one that create triggers from your script projects, then go to https://script.google.com > Triggers, there you will find a list of all the triggers created by your account.

I didn't tried it yet, but I think that one alternative is to enable the Google Apps Script API on the projects that create triggers and add a function to be called through Google Apps Script API to "log somewhere" the triggers created by that project.

Regarding to "log somewhere" maybe the easier setting is to email the log to the "active user".

Installable Triggers | Apps Script, Script executions and API requests do not cause triggers to run. by any user who has edit access, just like the simple onOpen() trigger. opens a spreadsheet, document, or form that they have permission to edit. From the script editor, choose Edit > Current project's triggers. Loop over all triggers. SELECT * FROM sys.triggers. It will list all triggers (DML and DDL) in the database. Here is the same query, with an added column called Parent_Object_Name which shows the table name for which the trigger was created (for DML triggers), and NULL for database (DDL) triggers: USE Database_Name SELECT OBJECT_NAME(parent_id) as Parent_Object_Name, *

Class ScriptApp | Apps Script, getUserTriggers(form), Trigger[], Gets all installable triggers owned by this Deletes all triggers in the current project. but are no longer used by the script are not included in the returned token. This is the preferred method to get the unique identifier for the script project as opposed to getProjectKey() . Select the page thumbnail corresponding to the page, and choose Page Properties from the options menu. Click the Actions tab. From the Select Trigger menu, choose Page Open to set an action when the page opens, or choose Page Close to set an action when the page closes. Choose an action from the Select Action menu, and click Add.

Triggers, Database events, such as logon/logoff, errors, or startup/shutdown, also issued However, do not confuse Oracle Forms triggers with the triggers discussed in this chapter. Make a complex security check on the current time or user A trigger defined at the database level fires for all users, and a trigger defined at the� A SQL Server trigger is a piece of procedural code, like a stored procedure which is only executed when a given event happens. There are different types of events that can fire a trigger. Just to name you a few, the insertion of rows in a table, a change in a table structure and even a user logging into a SQL Server instance.

Google Tag Manager Form Tracking, If you want to track all form submissions with Google Analytics, you'll need to If you have already opened that page with the form but don't see GTM's Setting just “thankyou” as the rule for this trigger might not be the best idea <script id=" gtm-jq-ajax-listen" type="text/javascript"> (function() { 'use strict';� Triggers constrain what transactions can do. A trigger does not apply to data loaded before the definition of the trigger. Therefore, it does not guarantee all data in a table conforms to its rules. A trigger enforces transitional constraints; that is, a trigger only enforces a constraint at the time that the data changes.

Comments