Google-apps-script – Create triggers on recently programmatically copied Google Forms

google-apps-scriptgoogle-forms

I have this main Form that uses its responses to create several other Forms after it's been submitted, but I need that these Forms that were recently created to send emails on their submissions without needing to edit manually each of their individual scripts.

Is there anyway I could do this using only the code and events from the main Form that triggers the creation of all those other forms?

Best Answer

To create triggers programmatically use Class Trigger Builder

forForm(form)

Creates and returns a FormTriggerBuilder tied to the given form.

 ScriptApp.newTrigger('myFunction')
   .forForm(FormApp.getActiveForm())
   .onFormSubmit()
   .create();