JASTechnology
JASTechnology

Reputation: 3

In Google Workplace apps, can I create a "forSpreadsheet" "onFormSubmit" trigger from within the Google Forms script?

I have an app current in the Google Workspace Marketplace. It's a Google Forms editor add-on and a Google Sheets editor add-on.

I'd like to make use of the "onFormSubmit" trigger of Sheets but have the trigger created interactively by the user while they are using Google Forms. I'd rather not have them jump over to Sheets to create this trigger.

Simple code here:

// Create a new trigger
const newTrigger = ScriptApp.newTrigger('respondToFormSubmit')
.forSpreadsheet(sheetId)
.onFormSubmit()
.create();

The event data of the Sheets version of the "onFormSubmit" trigger is just better for me as it includes the Range involved and I can target the newly created row more easily.

When testing locally it all works as expected. When I deploy and publish this Form script within my QA Google Workplace app the following behavior occurs:

  1. Trigger gets created perfectly and is associated with the correct Sheet.
  2. When the Google Form is completed it looks like the trigger does attempt to fire but it then is just marked as "Disabled" with a reason of "This trigger has been disabled for an unknown reason.".
  3. It does not appear an actual execution of this trigger even happened.

I have minimal code in that respondToFormSubmit function and the accepted permissions include editing rights for both Forms and Sheets and script.scriptapp.

Any ideas??? I really hope somebody has some idea or at least some more information here.

I tried uninstalling/re-installing with no improvement. I did confirm all permissions are consistent across everything.

Upvotes: 0

Views: 65

Answers (0)

Related Questions