Send feedback
  
   
 
  
    
      Base Service
    
    
      
      
      Stay organized with collections
     
    
      
      Save and categorize content based on your preferences.
     
   
     
  
  
  
   
  
  
    
      
  
  
    
      
        outlined_flag 
       
     
    
      
        
          The Base service provides access to user information and controls script logs and dialog boxes in Google Workspace applications.
         
      
        
          The service includes classes for handling data interchange (Blob, BlobSource), user interface elements (Browser, Button, ButtonSet, Menu, PromptResponse, Ui), logging (Logger, console), date and time (Month, Weekday), colors (ColorType, RgbColor), user session information (Session, User), and MIME types (MimeType).
         
      
        
          Several classes, like Browser and Ui, offer methods for displaying various types of dialog boxes and user interface elements.
         
      
        
          The Logger and console classes allow developers to write messages to execution logs and Google Cloud Logging for debugging and monitoring.
         
      
     
   
 
    
    
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 
Name Brief description 
 
Blob A data interchange object for Apps Script services. 
 
BlobSource  Interface for objects that can export their data as a Blob  
 
Browser This class provides access to dialog boxes specific to Google Sheets. 
 
Button An enum representing predetermined, localized dialog buttons returned by an alert PromptResponse.getSelectedButton()   
 
ButtonSet  An enum representing predetermined, localized sets of one or more dialog buttons that can be
added to an alert prompt  
 
ColorType  The types of Colors 
 
Logger This class allows the developer to write to the Execution log and to Google Cloud Logging  if the script is associated with
a standard
Cloud Project . 
 
Menu A custom menu in an instance of the user interface for a Google App. 
 
MimeType  An enumeration that provides access to MIME-type declarations without typing the strings
explicitly. 
 
Month An enum representing the months of the year. 
 
PromptResponse  A response to a prompt  
 
RgbColor  A color defined by red, green, blue color channels. 
 
Session The Session class provides access to session information, such as the user's email address (in
some circumstances) and language setting. 
 
Ui An instance of the user-interface environment for a Google App that allows the script to add
features like menus, dialogs, and sidebars. 
 
User Representation of a user, suitable for scripting. 
 
Weekday An enum representing the days of the week. 
 
console This class allows the developer to write to the Execution log and to Google Cloud Logging  if the script is associated with
a standard
Cloud Project . 
 
 
Methods 
Method Return type Brief description 
 
getAs(contentType)  Blob Return the data inside this object as a blob converted to the specified content type. 
 
getBlob()  Blob Return the data inside this object as a blob. 
 
 
 
Properties 
Property Type Description 
 
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. 
 
 
 
Properties 
Property Type Description 
 
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. 
 
 
 
Properties 
Property Type Description 
 
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. 
 
 
 
Methods 
Method Return type Brief description 
 
clear() voidClears the log. 
 
getLog()  StringReturns a complete list of messages in the current log. 
 
log(data) Logger Writes the data to the log. 
 
log(format, values) Logger Writes a formatted string to the logging console, using the format and values provided. 
 
 
 
Properties 
Property Type Description 
 
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). 
 
 
 
Properties 
Property Type Description 
 
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). 
 
 
 
Methods 
Method Return type Brief 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()   ColorType  Get 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. 
 
 
 
Properties 
Property Type Description 
 
ButtonButton An enum representing predetermined, localized dialog buttons returned by an alert  or PromptResponse.getSelectedButton()   
 
ButtonSet ButtonSet  An enum representing predetermined, localized sets of one or more dialog buttons that can be
added to an alert  or a prompt . 
 
 
Methods 
Method Return type Brief description 
 
alert(prompt) Button Opens a dialog box in the user's editor with the given message and an "OK" button. 
 
alert(prompt, buttons) Button Opens a dialog box in the user's editor with the given message and set of buttons. 
 
alert(title, prompt, buttons) Button Opens a dialog box in the user's editor with the given title, message, and set of buttons. 
 
createAddonMenu()   Menu Creates a builder that can be used to insert a sub-menu into the editor's Extensions menu. 
 
createMenu(caption)  Menu Creates a builder that can be used to add a menu to the editor's user interface. 
 
prompt(prompt) PromptResponse  Opens an input dialog box in the user's editor with the given message and an "OK" button. 
 
prompt(prompt, buttons) PromptResponse  Opens an input dialog box in the user's editor with the given message and set of buttons. 
 
prompt(title, prompt, buttons) PromptResponse  Opens 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. 
 
 
 
Methods 
Method Return type Brief description 
 
getEmail()  StringGets the user's email address, if available. 
 
 
 
Properties 
Property Type Description 
 
SUNDAYEnumSunday. 
 
MONDAYEnumMonday. 
 
TUESDAYEnumTuesday. 
 
WEDNESDAYEnumWednesday. 
 
THURSDAYEnumThursday. 
 
FRIDAYEnumFriday. 
 
SATURDAYEnumSaturday. 
 
 
 
Methods 
Method Return type Brief 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. 
 
 
 
 
  
  
     
  
    
    
      
    
     
  
       
         
  
  
    
    Send feedback
  
   
 
       
    
    
  
  
 
  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.
 
 
  
  
    
    
    
      
  
  
    Need to tell us more?
  
   
 
     
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[],[]]