Stay organized with collections Save and categorize content based on your preferences.
PromptResponseA response to a prompt
dialog displayed in the user-interface environment for a Google App. The response contains any text the user entered in the dialog's input field and indicates which button the user clicked to dismiss the dialog.
// Display a dialog box with a title, message, input field, and "Yes" and "No" // buttons. The user can also close the dialog by clicking the close button in // its title bar. const ui = DocumentApp.getUi(); const response = ui.prompt( 'Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO, ); // Process the user's response. if (response.getSelectedButton() === ui.Button.YES) { Logger.log('The user\'s name is %s.', response.getResponseText()); } else if (response.getSelectedButton() === ui.Button.NO) { Logger.log('The user didn\'t want to provide a name.'); } else { Logger.log('The user clicked the close button in the dialog\'s title bar.'); }Methods Method Return type Brief description
getResponseText()
String
Gets the text that the user entered in the dialog's input field. getSelectedButton()
Button
Gets the button that the user clicked to dismiss the dialog. Detailed documentation getResponseText()
Gets the text that the user entered in the dialog's input field. The text is available even if the user closed the dialog by clicking a button with a negative connotation, like "Cancel" or the close button in the dialog's title bar. getSelectedButton()
can help to determine whether the user intended the response text to be valid.
String
— The text that the user entered in the dialog's input field.
getSelectedButton()
Gets the button that the user clicked to dismiss the dialog. If the user clicked the close button that is included in every dialog's title bar, this method returns Button.CLOSE
.
Button
— The button that the user clicked.
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.
[[["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."],[[["`PromptResponse` objects store user input and button selections from prompts in Google Apps Script UI."],["`getResponseText()` retrieves the text entered by the user in the prompt's input field."],["`getSelectedButton()` identifies which button the user clicked to close the prompt (e.g., YES, NO, CLOSE)."],["This data allows scripts to react differently based on user interaction with the prompt dialog."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4