Class FormTriggerBuilder

  • FormTriggerBuilder helps in creating custom triggers for Google Forms.

  • It offers methods to set triggers for form submission (onFormSubmit()) and form opening (onOpen()).

  • create() method finalizes and returns the new trigger.

  • Triggers execute specified functions (myFunction in the examples) when the defined event (submit or open) occurs.

FormTriggerBuilder

A builder for form triggers.

Methods

MethodReturn typeBrief description
create()TriggerCreates and returns the new trigger.
onFormSubmit()FormTriggerBuilderSpecifies a trigger that will fire when a response is submitted to the form.
onOpen()FormTriggerBuilderSpecifies a trigger that will fire when the form's edit view is opened.

Detailed documentation

create()

Creates and returns the new trigger.

Return

Trigger — The new trigger.


onFormSubmit()

Specifies a trigger that will fire when a response is submitted to the form.

const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
ScriptApp.newTrigger('myFunction').forForm(form).onFormSubmit().create();

Return

FormTriggerBuilder — this FormTriggerBuilder, for chaining


onOpen()

Specifies a trigger that will fire when the form's edit view is opened.

const form = FormApp.getActiveForm();
ScriptApp.newTrigger('myFunction').forForm(form).onOpen().create();

Return

FormTriggerBuilder — This FormTriggerBuilder, for chaining.