Custom Dialogs

Custom dialogs in Apps Script allow you to create pop-up windows with custom inputs, messages, and buttons. These are useful for creating forms, inputting data, and obtaining user input.

To create a custom dialog, you can use the ui class provided by Apps Script. This class provides methods for creating different types of dialogs such as alert, prompt, and custom dialogs.

Here is an example of creating a custom dialog in Apps Script:

function showCustomDialog() {
  var ui = SpreadsheetApp.getUi();
  var response = ui.prompt(
    'Please enter your name:',

  // Process the user's response
  if (response.getSelectedButton() == ui.Button.OK) {
    Logger.log('The user entered: ' + response.getResponseText());

In this example, we are using the ui.prompt() method to create a custom dialog box that prompts the user to enter their name. We also provide an OK/CANCEL button set to allow the user to confirm or cancel their input.

When the user clicks the OK button, the script logs their input to the console using the Logger.log() method.

Custom dialogs can be used for a variety of purposes, such as collecting data from users or displaying informative messages. The ui class provides additional methods for creating custom dialogs with different input types, such as checkboxes, radio buttons, and dropdown menus.