Enum ButtonSet

  • ButtonSet is an enum in Apps Script for creating predetermined, localized sets of dialog buttons for alerts and prompts.

  • You can determine which button a user clicks by using the Button class in conjunction with ButtonSet.

  • Enum properties are accessed by calling the parent class, name, and property, such asBase.ButtonSet.OK.

  • Common ButtonSet properties include OK, OK_CANCEL, YES_NO, and YES_NO_CANCEL, each offering different combinations of buttons for various dialog scenarios.

ButtonSet

An enum representing predetermined, localized sets of one or more dialog buttons that can beadded to analert or aprompt. To determine which button the user clicked,useButton.

To call an enum, you call its parent class, name, and property. For example,Base.ButtonSet.OK.

// Display a dialog box with a message and "Yes" and "No" buttons.constui=DocumentApp.getUi();constresponse=ui.alert('Are you sure you want to continue?',ui.ButtonSet.YES_NO,);// Process the user's response.if(response===ui.Button.YES){Logger.log('The user clicked "Yes."');}else{Logger.log('The user clicked "No" or the dialog\'s close button.');}

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 anoperation.
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 ayes/no question or halt an operation.

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.