Hi and Good day to all,
Google App Script can be used in so many ways. I know cause I have tried some of them but Iam not an expert so, the situation is.
I have created an Spreadsheet
create a form using the new UI Building that comes with the script editor.
named:gtest01
UI compose of:
- label, id=label_caption
- button 1, id=button_hide, event-onmouseclick=hide_label
- button 2, id=button_show, event-onmouseclick=show_label
- button 3, id=button_message, event-onmouseclick=message_me
now, the code is:
/* This is so when I want to just deploy it as a [webapp] using the
script editor -> Publish Deploy as Web App
*/
function doGet(e) {
var app = UiApp.createApplication().setTitle("Sheet Application");
app.add(app.loadComponent("gtest01"));
Logger.log("Application UI Loaded");
return app;
}
function message_me(e) {
Browser.msgBox("my message");
}
function hide_label(e) {
var app = UiApp.getActiveApplication();
label =app.getElementById("label_caption");
label.setVisible(false);
}
function show_label(e) {
var app = UiApp.getActiveApplication();
label =app.getElementById("label_caption");
label.setVisible(true);
}
// this code is for when the spreadsheet is shared so they can access the form
function showform_() {
var app = UiApp.createApplication();
app.add(app.loadComponent("gtest01"));
SpreadsheetApp.getActiveSpreadsheet().show(app);
}
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [];
menuEntries.push({name: "Show Form", functionName: "showform_"});
ss.addMenu("e-Test", menuEntries);
}
First scenario is that when spreadsheet is shared
- when menu is clicked the form will load – thats good
- when show and hide button nothing happens – why and how can i fixed
this? - when message button is click – message will show but the form will
close, how can I display a message without closing the form?
Second scenario is that when publish as Webapp.
- When Developer Link is Access the UI is always updated – ok
- When URL Link is Access the UI is always updated its like it is
cache, how can I fixed this? - on dev link: when show and hide button nothing happens – why and how
can i fixed this? - on dev link: when message button is click – will generate an error,
how can I display an alert message on WebApp
Please help I have search and tried the sample codes and answer in the forum am missing something.
Thanks
Nick Ace
First scenario
when show and hide button nothing happens – why and how can i fixed this?
In your functions, use return app at the end. Unless you return the app object, the UI doesn’t get updated.
how can I display a message without closing the form? – Try
SpreadsheetApp.getActiveSpreadsheet().toast()2nd scenario
When URL Link is Access the UI is always updated its like it is cache, how can I fixed this? – Save your most recent code as a version
on dev link: when show and hide button nothing happens – Again return app will take care of this
on dev link: when message button is click… – Browser.msgBox is not supported in a web app.