Base Service

Base

This service provides access to user information such as email addresses and user names. It also controls script logs and dialog boxes in Google Workspace applications.

Classes

NameBrief description
BlobA data interchange object for Apps Script services.
BlobSourceInterface for objects that can export their data as a Blob.
BrowserThis class provides access to dialog boxes specific to Google Sheets.
ButtonAn enum representing predetermined, localized dialog buttons returned by an alert or PromptResponse.getSelectedButton() to indicate which button in a dialog the user clicked.
ButtonSetAn enum representing predetermined, localized sets of one or more dialog buttons that can be added to an alert or a prompt.
ColorTypeThe types of Colors
LoggerThis class allows the developer to write out text to the debugging logs.
MenuA custom menu in an instance of the user interface for a Google App.
MimeTypeAn enumeration that provides access to MIME-type declarations without typing the strings explicitly.
MonthAn enum representing the months of the year.
PromptResponseA response to a prompt dialog displayed in the user-interface environment for a Google App.
RgbColorA color defined by red, green, blue color channels.
SessionThe Session class provides access to session information, such as the user's email address (in some circumstances) and language setting.
UiAn instance of the user-interface environment for a Google App that allows the script to add features like menus, dialogs, and sidebars.
UserRepresentation of a user, suitable for scripting.
WeekdayAn enum representing the days of the week.
consoleThis class allows the developer to write logs to the Google Cloud Platform's Stackdriver Logging service.

Blob

Methods

MethodReturn typeBrief description
copyBlob()BlobReturns a copy of this blob.
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBytes()Byte[]Gets the data stored in this blob.
getContentType()StringGets the content type of the bytes in this blob.
getDataAsString()StringGets the data of this blob as a String with UTF-8 encoding.
getDataAsString(charset)StringGets the data of this blob as a string with the specified encoding.
getName()StringGets the name of this blob.
isGoogleType()BooleanReturns whether this blob is a Google Workspace file (Sheets, Docs, etc.).
setBytes(data)BlobSets the data stored in this blob.
setContentType(contentType)BlobSets the content type of the bytes in this blob.
setContentTypeFromExtension()BlobSets the content type of the bytes in this blob based on the file extension.
setDataFromString(string)BlobSets the data of this blob from a string with UTF-8 encoding.
setDataFromString(string, charset)BlobSets the data of this blob from a string with the specified encoding.
setName(name)BlobSets the name of this blob.

BlobSource

Methods

MethodReturn typeBrief description
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBlob()BlobReturn the data inside this object as a blob.

Browser

Properties

PropertyTypeDescription
ButtonsButtonSet

Methods

MethodReturn typeBrief description
inputBox(prompt)StringPops up a dialog box with a text input box in the user's browser.
inputBox(prompt, buttons)StringPops up a dialog box with a text input box in the user's browser.
inputBox(title, prompt, buttons)StringPops up a dialog box with a text input box in the user's browser.
msgBox(prompt)StringPops up a dialog box with the given message and an OK button in the user's browser.
msgBox(prompt, buttons)StringPops up a dialog box with the given message and specified buttons in the user's browser.
msgBox(title, prompt, buttons)StringPops up a dialog box with the given title, message and specified buttons in the user's browser.

Button

Properties

PropertyTypeDescription
CLOSEEnumThe standard close button displayed in every dialog's title bar.
OKEnumAn "OK" button, indicating that an operation should proceed.
CANCELEnumA "Cancel" button, indicating that an operation should not proceed.
YESEnumA "Yes" button, indicating a positive response to a question.
NOEnumA "No" button, indicating a negative response to a question.

ButtonSet

Properties

PropertyTypeDescription
OKEnumA single "OK" button, indicating an informational message that can only be dismissed.
OK_CANCELEnumAn "OK" button and a "Cancel" button, allowing the user to either proceed with or halt an operation.
YES_NOEnumA "Yes" button and a "No" button, allowing the user to answer a yes/no question.
YES_NO_CANCELEnumA "Yes" button, a "No" button, and a "Cancel" button, allowing the user to either answer a yes/no question or halt an operation.

ColorType

Properties

PropertyTypeDescription
UNSUPPORTEDEnumA color type that is not supported.
RGBEnumA color defined by red, green, blue color channels.
THEMEEnumA color that refers to an entry in the theme's color scheme.

Logger

Methods

MethodReturn typeBrief description
clear()voidClears the log.
getLog()StringReturns a complete list of messages in the current log.
log(data)LoggerWrites the string to the logging console.
log(format, values)LoggerWrites a formatted string to the logging console, using the format and values provided.

Methods

MethodReturn typeBrief description
addItem(caption, functionName)MenuAdds an item to the menu.
addSeparator()MenuAdds a visual separator to the menu.
addSubMenu(menu)MenuAdds a sub-menu to the menu.
addToUi()voidInserts the menu into the instance of the editor's user interface.

MimeType

Properties

PropertyTypeDescription
GOOGLE_APPS_SCRIPTEnumRepresentation of MIME type for a Google Apps Script project.
GOOGLE_DRAWINGSEnumRepresentation of MIME type for a Google Drawings file.
GOOGLE_DOCSEnumRepresentation of MIME type for a Google Docs file.
GOOGLE_FORMSEnumRepresentation of MIME type for a Google Forms file.
GOOGLE_SHEETSEnumRepresentation of MIME type for a Google Sheets file.
GOOGLE_SITESEnumRepresentation of MIME type for a Google Sites file.
GOOGLE_SLIDESEnumRepresentation of MIME type for a Google Slides file.
FOLDEREnumRepresentation of MIME type for a Google Drive folder.
SHORTCUTEnumRepresentation of MIME type for a Google Drive shortcut.
BMPEnumRepresentation of MIME type for a BMP image file (typically .bmp).
GIFEnumRepresentation of MIME type for a GIF image file (typically .gif).
JPEGEnumRepresentation of MIME type for a JPEG image file (typically .jpg).
PNGEnumRepresentation of MIME type for a PNG image file (typically .png).
SVGEnumRepresentation of MIME type for an SVG image file (typically .svg).
PDFEnumRepresentation of MIME type for a PDF file (typically .pdf).
CSSEnumRepresentation of MIME type for a CSS text file (typically .css).
CSVEnumRepresentation of MIME type for a CSV text file (typically .csv).
HTMLEnumRepresentation of MIME type for an HTML text file (typically .html).
JAVASCRIPTEnumRepresentation of MIME type for a JavaScript text file (typically .js).
PLAIN_TEXTEnumRepresentation of MIME type for a plain text file (typically .txt).
RTFEnumRepresentation of MIME type for a rich text file (typically .rtf).
OPENDOCUMENT_GRAPHICSEnumRepresentation of MIME type for an OpenDocument graphics file (typically .odg).
OPENDOCUMENT_PRESENTATIONEnumRepresentation of MIME type for an OpenDocument presentation file (typically .odp).
OPENDOCUMENT_SPREADSHEETEnumRepresentation of MIME type for an OpenDocument spreadsheet file (typically .ods).
OPENDOCUMENT_TEXTEnumRepresentation of MIME type for an OpenDocument word-processing file (typically .odt).
MICROSOFT_EXCELEnumRepresentation of MIME type for a Microsoft Excel spreadsheet file (typically .xlsx).
MICROSOFT_EXCEL_LEGACYEnumRepresentation of MIME type for a Microsoft Excel legacy file (typically .xls).
MICROSOFT_POWERPOINTEnumRepresentation of MIME type for a Microsoft PowerPoint presentation file (typically .pptx).
MICROSOFT_POWERPOINT_LEGACYEnumRepresentation of MIME type for a Microsoft PowerPoint legacy file (typically .ppt).
MICROSOFT_WORDEnumRepresentation of MIME type for a Microsoft Word document file (typically .docx).
MICROSOFT_WORD_LEGACYEnumRepresentation of MIME type for a Microsoft Word legacy file (typically .doc).
ZIPEnumRepresentation of MIME type for a ZIP archive file (typically .zip).

Month

Properties

PropertyTypeDescription
JANUARYEnumJanuary (month 1).
FEBRUARYEnumFebruary (month 2).
MARCHEnumMarch (month 3).
APRILEnumApril (month 4).
MAYEnumMay (month 5).
JUNEEnumJune (month 6).
JULYEnumJuly (month 7).
AUGUSTEnumAugust (month 8).
SEPTEMBEREnumSeptember (month 9).
OCTOBEREnumOctober (month 10).
NOVEMBEREnumNovember (month 11).
DECEMBEREnumDecember (month 12).

PromptResponse

Methods

MethodReturn typeBrief description
getResponseText()StringGets the text that the user entered in the dialog's input field.
getSelectedButton()ButtonGets the button that the user clicked to dismiss the dialog.

RgbColor

Methods

MethodReturn typeBrief description
asHexString()StringReturns the color as a CSS-style 7 character hexadecimal string (#rrggbb) or 9 character hexadecimal string (#aarrggbb).
getBlue()IntegerThe blue channel of this color, as a number from 0 to 255.
getColorType()ColorTypeGet the type of this color.
getGreen()IntegerThe green channel of this color, as a number from 0 to 255.
getRed()IntegerThe red channel of this color, as a number from 0 to 255.

Session

Methods

MethodReturn typeBrief description
getActiveUser()UserGets information about the current user.
getActiveUserLocale()StringGets the language setting of the current user as a string—for example, en for English.
getEffectiveUser()UserGets information about the user under whose authority the script is running.
getScriptTimeZone()StringGets the time zone of the script.
getTemporaryActiveUserKey()StringGets a temporary key that is unique to the active user but does not reveal the user identity.

Ui

Properties

PropertyTypeDescription
ButtonButtonAn enum representing predetermined, localized dialog buttons returned by an alert or PromptResponse.getSelectedButton() to indicate which button in a dialog the user clicked.
ButtonSetButtonSetAn enum representing predetermined, localized sets of one or more dialog buttons that can be added to an alert or a prompt.

Methods

MethodReturn typeBrief description
alert(prompt)ButtonOpens a dialog box in the user's editor with the given message and an "OK" button.
alert(prompt, buttons)ButtonOpens a dialog box in the user's editor with the given message and set of buttons.
alert(title, prompt, buttons)ButtonOpens a dialog box in the user's editor with the given title, message, and set of buttons.
createAddonMenu()MenuCreates a builder that can be used to insert a sub-menu into the editor's Extensions menu.
createMenu(caption)MenuCreates a builder that can be used to add a menu to the editor's user interface.
prompt(prompt)PromptResponseOpens an input dialog box in the user's editor with the given message and an "OK" button.
prompt(prompt, buttons)PromptResponseOpens an input dialog box in the user's editor with the given message and set of buttons.
prompt(title, prompt, buttons)PromptResponseOpens an input dialog box in the user's editor with the given title, message, and set of buttons.
showModalDialog(userInterface, title)voidOpens a modal dialog box in the user's editor with custom client-side content.
showModelessDialog(userInterface, title)voidOpens a modeless dialog box in the user's editor with custom client-side content.
showSidebar(userInterface)voidOpens a sidebar in the user's editor with custom client-side content.

User

Methods

MethodReturn typeBrief description
getEmail()StringGets the user's email address, if available.

Weekday

Properties

PropertyTypeDescription
SUNDAYEnumSunday.
MONDAYEnumMonday.
TUESDAYEnumTuesday.
WEDNESDAYEnumWednesday.
THURSDAYEnumThursday.
FRIDAYEnumFriday.
SATURDAYEnumSaturday.

console

Methods

MethodReturn typeBrief description
error()voidOutputs a blank ERROR level message to Stackdriver Logging.
error(formatOrObject, values)voidOutputs an ERROR level message to Stackdriver Logging.
info()voidOutputs blank INFO level message to Stackdriver Logging.
info(formatOrObject, values)voidOutputs an INFO level message to Stackdriver Logging.
log()voidOutputs a blank DEBUG level message to Stackdriver Logging.
log(formatOrObject, values)voidOutputs a DEBUG level message to Stackdriver Logging.
time(label)voidStarts a timer you can use to track how long an operation takes.
timeEnd(label)voidStops a timer that was previously started by calling console.time().
warn()voidOutputs a blank WARNING level message to Stackdriver Logging.
warn(formatOrObject, values)voidOutputs a WARNING level message to Stackdriver Logging.