Class DocumentTriggerBuilder
Stay organized with collections
Save and categorize content based on your preferences.
DocumentTriggerBuilder
A builder for document triggers.
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.
const document = DocumentApp.getActiveDocument();
ScriptApp.newTrigger('myFunction').forDocument(document).onOpen().create();
Return
DocumentTriggerBuilder
— This DocumentTriggerBuilder
, for chaining.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[null,null,["Last updated 2024-12-02 UTC."],[],["The `DocumentTriggerBuilder` class facilitates the creation of triggers for Google Documents. Key actions include `create()`, which generates and returns a new `Trigger` object, and `onOpen()`, which configures the trigger to activate when the document is opened. The `onOpen()` method returns the `DocumentTriggerBuilder` instance, allowing method chaining. The provided example demonstrates creating a trigger that runs \"myFunction\" upon document opening.\n"],null,[]]