Mantenha tudo organizado com as coleções Salve e categorize o conteúdo com base nas suas preferências.
Resposta imediata
Uma resposta a uma caixa de diálogo prompt exibida no ambiente da interface do usuário de um app do Google. A resposta contém qualquer texto que o usuário digitou no campo de entrada da caixa de diálogo e indica em qual botão o usuário clicou para dispensar a caixa de diálogo.
// 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.constui=DocumentApp.getUi();constresponse=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());}elseif(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.');}
Recebe o botão em que o usuário clicou para dispensar a caixa de diálogo.
Documentação detalhada
getResponseText()
Recebe o texto que o usuário digitou no campo de entrada da caixa de diálogo. O texto fica disponível mesmo se o usuário fechar a caixa de diálogo clicando em um botão com uma conotação negativa, como "Cancelar" ou o botão de fechamento na barra de título da caixa de diálogo. O getSelectedButton() pode ajudar a determinar se o usuário pretendia que o texto da resposta fosse válido.
Retornar
String: o texto que o usuário digitou no campo de entrada da caixa de diálogo.
getSelectedButton()
Recebe o botão em que o usuário clicou para dispensar a caixa de diálogo. Se o usuário clicar no botão de fechar incluído na barra de título de cada caixa de diálogo, esse método retornará Button.CLOSE.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003ePromptResponse\u003c/code\u003e objects store user input and button selections from prompts in Google Apps Script UI.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetResponseText()\u003c/code\u003e retrieves the text entered by the user in the prompt's input field.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetSelectedButton()\u003c/code\u003e identifies which button the user clicked to close the prompt (e.g., YES, NO, CLOSE).\u003c/p\u003e\n"],["\u003cp\u003eThis data allows scripts to react differently based on user interaction with the prompt dialog.\u003c/p\u003e\n"]]],[],null,["PromptResponse\n\nA response to a [prompt](/apps-script/reference/base/ui#prompt(String)) dialog displayed in the\nuser-interface environment for a Google App. The response contains any text the user entered in\nthe dialog's input field and indicates which button the user clicked to dismiss the dialog.\n\n```javascript\n// Display a dialog box with a title, message, input field, and \"Yes\" and \"No\"\n// buttons. The user can also close the dialog by clicking the close button in\n// its title bar.\nconst ui = DocumentApp.getUi();\nconst response = ui.prompt(\n 'Getting to know you',\n 'May I know your name?',\n ui.ButtonSet.YES_NO,\n);\n\n// Process the user's response.\nif (response.getSelectedButton() === ui.Button.YES) {\n Logger.log('The user\\'s name is %s.', response.getResponseText());\n} else if (response.getSelectedButton() === ui.Button.NO) {\n Logger.log('The user didn\\'t want to provide a name.');\n} else {\n Logger.log('The user clicked the close button in the dialog\\'s title bar.');\n}\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|---------------------------------------------|----------------------------------------------|------------------------------------------------------------------|\n| [getResponseText()](#getResponseText()) | `String` | Gets the text that the user entered in the dialog's input field. |\n| [getSelectedButton()](#getSelectedButton()) | [Button](/apps-script/reference/base/button) | Gets the button that the user clicked to dismiss the dialog. |\n\nDetailed documentation \n\n`get``Response``Text()` \nGets the text that the user entered in the dialog's input field. The text is available even if\nthe user closed the dialog by clicking a button with a negative connotation, like \"Cancel\" or\nthe close button in the dialog's title bar. [getSelectedButton()](#getSelectedButton()) can help to determine\nwhether the user intended the response text to be valid.\n\nReturn\n\n\n`String` --- The text that the user entered in the dialog's input field.\n\n*** ** * ** ***\n\n`get``Selected``Button()` \nGets the button that the user clicked to dismiss the dialog. If the user clicked the close\nbutton that is included in every dialog's title bar, this method returns [Button.CLOSE](/apps-script/reference/base/button#CLOSE).\n\nReturn\n\n\n[Button](/apps-script/reference/base/button) --- The button that the user clicked."]]