Class DocumentTriggerBuilder

  • DocumentTriggerBuilder is used to build document triggers.

  • Thecreate() method creates and returns the new trigger.

  • TheonOpen() method specifies a trigger that fires when a document is opened.

DocumentTriggerBuilder

A builder for document triggers.

Methods

MethodReturn typeBrief description
create()TriggerCreates and returns the new trigger.
onOpen()DocumentTriggerBuilderSpecifies a trigger that will fire when the document is opened.

Detailed documentation

create()

Creates and returns the new trigger.

Return

Trigger — The new trigger.


onOpen()

Specifies a trigger that will fire when the document is opened.

constdocument=DocumentApp.getActiveDocument();ScriptApp.newTrigger('myFunction').forDocument(document).onOpen().create();

Return

DocumentTriggerBuilder — ThisDocumentTriggerBuilder, for chaining.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.