I am trying to create a web app using Google app script, that if you press a button, you may get an alert message.
In the home.gs file I tried this :
function let_user_decide()
{
Browser.msgBox('Greetings', 'Press Yes or No?', Browser.Buttons.YES_NO);
};
unfortunately I keep getting this when I press the button when I should get the alert message :
Exception: Cannot call Browser.inputBox() from this context.
Important to mention : my script is using Google spreadsheet but the msgBox should appear in the webapp! In addition, I use HTML
Any idea what am I doing wrong? And how can I fix it?
At the top right of the script project, click Deploy > Test deployments. Next to "Select type," click Enable deployment types settings > Web app. Under the web app URL, click Copy. Paste the URL in your browser and test your web app.
Triggers let Apps Script run a function automatically when a certain event, like opening a document, occurs. Simple triggers are a set of reserved functions built into Apps Script, like the function onOpen(e) , which executes when a user opens a Google Docs, Sheets, Slides, or Forms file.
Handle POST Requests with Google ScriptsThe callback function doPost is invoked when an HTTP POST request is make to your Google Script URL that is published as a web app with anonymous access. const doPost = (request) => { console. log(request); return ContentService. crateTextOutput(JSON.
Browser.msgBox is indeed only available in the spreadsheet interface, not in webapps.
You have a lot of alternatives to throw alerts but you should mention wether you use UiApp or HTML Service.
In UiApp you can create a popupPanel for example while in HTML you can throw alerts (throw new Error('sample alert')) or use JQuery Ui elements to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With