Click here to see your recently viewed pages and most viewed pages.
Hide
Apps Script

Script Service

Script

This service provides access to script triggers and script publishing.

Classes

NameBrief description
AuthModeAn enumeration that identifies which categories of authorized services Apps Script is able to execute through a triggered function.
AuthorizationInfoAn object used to determine whether the user needs to authorize this script to use one or more services, and to provide the URL for an authorization dialog.
AuthorizationStatusAn enumeration denoting the authorization status of a script.
ClockTriggerBuilderA builder for clock triggers.
DocumentTriggerBuilderA builder for document triggers.
EventTypeAn enumeration denoting the type of triggered event.
FormTriggerBuilderA builder for form triggers.
ScriptAppAccess and manipulate script publishing and triggers.
ServiceAccess and manipulate script publishing.
Service.Restriction
SpreadsheetTriggerBuilderBuilder for spreadsheet triggers.
StateTokenBuilderAllows scripts to create state tokens that can be used in callback APIs (like OAuth flows).
TriggerA script trigger.
TriggerBuilderA generic builder for script triggers.
TriggerSourceAn enumeration denoting the source of the event that causes the trigger to fire.

Class AuthMode

Properties

PropertyTypeDescription
NONEEnumA mode that does not allow access to any services that require authorization.
CUSTOM_FUNCTIONEnumA mode that allows access to a limited subset of services for use in custom spreadsheet functions.
LIMITEDEnumA mode that allows access to a limited subset of services.
FULLEnumA mode that allows access to all services that require authorization.

Class AuthorizationInfo

Methods

MethodReturn typeBrief description
getAuthorizationStatus()AuthorizationStatusGets a value that indicates whether the user needs to authorize this script to use one or more services (for example, ScriptApp.AuthorizationStatus.REQUIRED).
getAuthorizationUrl()StringGets the authorization URL that can be used to grant access to the script.

Class AuthorizationStatus

Properties

PropertyTypeDescription
REQUIREDEnumThe user needs to authorize this script to use one or more services.
NOT_REQUIREDEnumThe user has granted this script all the authorization it currently requires.

Class ClockTriggerBuilder

Methods

MethodReturn typeBrief description
after(durationMilliseconds)ClockTriggerBuilderSpecifies the duration (in milliseconds) after the current time that the trigger will run.
at(date)ClockTriggerBuilderSpecifies when the trigger will run (plus or minus 15 minutes).
atDate(year, month, day)ClockTriggerBuilderSpecifies trigger will fire on the given date, by default near midnight (+/- 15 minutes).
atHour(hour)ClockTriggerBuilderSpecifies the hour the trigger will run (plus or minus 15 minutes).
create()TriggerCreates the trigger.
everyDays(n)ClockTriggerBuilderSpecifies to run the trigger every n days.
everyHours(n)ClockTriggerBuilderSpecifies to run the trigger every n hours.
everyMinutes(n)ClockTriggerBuilderSpecifies to run the trigger every n minutes.
everyWeeks(n)ClockTriggerBuilderSpecifies to run the trigger every n weeks.
inTimezone(timezone)ClockTriggerBuilderSpecifies the timezone that the specified dates/time that the trigger will run in.
nearMinute(minute)ClockTriggerBuilderSpecifies the minute the trigger will run (plus or minus 15 minutes).
onMonthDay(day)ClockTriggerBuilderSpecifies on what date in the month that the trigger will run.
onWeekDay(day)ClockTriggerBuilderSpecifies on what day of the week that the trigger will run.

Class DocumentTriggerBuilder

Methods

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

Class EventType

Properties

PropertyTypeDescription
CLOCKEnumThe trigger fires once the time-driven event reaches a specific time.
ON_OPENEnumThe trigger fires once the user opens the Google Docs, Sheets, or Forms file.
ON_EDITEnumThe trigger fires once the user edits the Google Sheets file (for example, by entering a new value into a cell, which counts as an edit instead of a change).
ON_FORM_SUBMITEnumThe trigger fires once the user responds to a Google Form.
ON_CHANGEEnumThe trigger fires once the user changes the Google Sheets file (for example, by adding a row, which counts as a change instead of an edit).

Class FormTriggerBuilder

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.

Class ScriptApp

Properties

PropertyTypeDescription
AuthModeAuthModeAn enumeration that identifies which categories of authorized services Apps Script is able to execute through a triggered function.
AuthorizationStatusAuthorizationStatusAn enumeration denoting the authorization status of a script.
EventTypeEventTypeAn enumeration denoting the type of triggered event.
TriggerSourceTriggerSourceAn enumeration denoting the source of the event that causes the trigger to fire.
WeekDayWeekdayAn enumeration representing the days of the week.

Methods

MethodReturn typeBrief description
deleteTrigger(trigger)voidRemoves the given trigger so it will no longer run.
getAuthorizationInfo(authMode)AuthorizationInfoGets an object used to determine whether the user needs to authorize this script to use one or more services, and to provide the URL for an authorization dialog.
getOAuthToken()StringGets the OAuth 2.0 access token for the current user.
getProjectTriggers()Trigger[]Gets all installable triggers associated with the current project.
getService()ServiceGets an object used to control publishing the script as a web app.
getUserTriggers(document)Trigger[]Gets all installable triggers owned by this user in the given document.
getUserTriggers(form)Trigger[]Gets all installable triggers owned by this user in the given form.
getUserTriggers(spreadsheet)Trigger[]Gets all installable triggers owned by this user in the given spreadsheet.
invalidateAuth()voidInvalidates the authorization this user has to execute the current script.
newStateToken()StateTokenBuilderCreates a builder for a state token that can be used in a callback API (like an OAuth flow).
newTrigger(functionName)TriggerBuilderBegins the process of creating an installable trigger that, when fired, will call a given function.

Class Service

Properties

PropertyTypeDescription
RestrictionService.RestrictionEnum representing the access restrictions on a script exported as a service.

Methods

MethodReturn typeBrief description
disable()voidDisables the script from being accessed as a web app.
enable(restriction)voidAllows the script to be accessed as a web app with the specified permissions.
getUrl()StringReturns the URL of the web app, if it has been deployed; otherwise returns null.
isEnabled()BooleanReturns true if the script is accessible as a web app.

Class Service.Restriction

Properties

PropertyTypeDescription
MYSELFEnumYou are the only one who has access to the web app.
DOMAINEnumEveryone within your domain/organization has access to the web app.
ALLEnumAnyone can publicly access the web app.

Class SpreadsheetTriggerBuilder

Methods

MethodReturn typeBrief description
create()TriggerCreates the trigger and returns it.
onChange()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet's content or structure is changed.
onEdit()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet is edited.
onFormSubmit()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet has a form submitted to it.
onOpen()SpreadsheetTriggerBuilderSpecifies a trigger that will fire when the spreadsheet is opened.

Class StateTokenBuilder

Methods

MethodReturn typeBrief description
createToken()StringConstructs an encrypted string representation of the state token.
withArgument(name, value)StateTokenBuilderAdds an argument to the token.
withMethod(method)StateTokenBuilderSets a callback function.
withTimeout(seconds)StateTokenBuilderSets the duration (in seconds) for which the token is valid.

Class Trigger

Methods

MethodReturn typeBrief description
getEventType()EventTypeReturns the event type that the trigger fires on.
getHandlerFunction()StringReturns the function that will be called when the trigger fires.
getTriggerSource()TriggerSourceReturns the source of events that will cause the trigger to fire.
getTriggerSourceId()StringReturns the id specific to the source.
getUniqueId()StringReturns a unique identifier that can be used to distinguish triggers from each other.

Class TriggerBuilder

Methods

MethodReturn typeBrief description
forDocument(document)DocumentTriggerBuilderCreates and returns a DocumentTriggerBuilder tied to the given document.
forDocument(key)DocumentTriggerBuilderCreates and returns a DocumentTriggerBuilder tied to the document with the given ID.
forForm(form)FormTriggerBuilderCreates and returns a FormTriggerBuilder tied to the given form.
forForm(key)FormTriggerBuilderCreates and returns a FormTriggerBuilder tied to the form with the given ID.
forSpreadsheet(sheet)SpreadsheetTriggerBuilderCreates and returns a SpreadsheetTriggerBuilder tied to the given spreadsheet.
forSpreadsheet(key)SpreadsheetTriggerBuilderCreates and returns a SpreadsheetTriggerBuilder tied to the spreadsheet with the given ID.
timeBased()ClockTriggerBuilderCreates and returns a ClockTriggerBuilder for building time-based triggers.

Class TriggerSource

Properties

PropertyTypeDescription
SPREADSHEETSEnumGoogle Sheets causes the trigger to fire.
CLOCKEnumA time-driven event causes the trigger to fire.
FORMSEnumGoogle Forms causes the trigger to fire.
DOCUMENTSEnumGoogle Docs causes the trigger to fire.