Liz Sparks
Liz Sparks

Reputation: 1

Google apps GUI builder not passing callback elements to script

Ok, so I'm using the google apps GUI builder and I've defined a simple textBox widget, with the ID and name properties both set to 'TextB1'.

I've also defined a button.

I've added a handler to the button mouse click event, together with the callback element set to 'TextB1'.

In my handler function i have the code :

Browser.msgBox(e.parameter.TextB1);

and when I run everything, click the button and the handler is invoked, it hits this line and says 'undefined'. ...

Iv'e tried numerous possibilities with different widget types, using copy and paste to ensure no typo's etc, and absolutely nothing works. finally , I reduced everything to this simple example, with the id and name set to the same value, to avoid any possibility of my using the wrong reference in the wrong place.

But even with this simple example, I have no idea what I'm doing wrong. I'm not really a javascript programmer, although I have over a a couple of decade of windows/c/c#/unix etc so I really thought this would be very trivial, but am completely floored (or perhaps my code is completely flawed ;) ! ) ... Either way if anyone wants to point out the error of my ways, and spot the mistake I would be very grateful, as it's driving me nuts.

Interesting to note that other people have had this problem, but aside from pointing out that the Name property as well as Id for the widget needs to be set, several have said the problem just went away... Is it an intermittent bug or am I doing something daft?.

Any help welcome or advice on other obvious mistakes welcome...

Upvotes: 0

Views: 182

Answers (1)

Warwick
Warwick

Reputation: 429

I was having the same problem, but thanks to your hint about setting the "Name" property I got it working.

I too am using the GUI builder. I replicated this example code:

https://developers.google.com/apps-script/class_textbox

into the equivalent in the GUI builder, but changed:

app.getElementById("label").setText(eventInfo...

to:

app.getElementById("label").setText(Utilities.jsonStringify(eventInfo));

This gives a bit more insight into what is actually passed to the callback. And I'm not able to use msgBox because mine's a webapp. Some people say you need to use a basic button (as I am and as in this example) not a submit button. Make sure you make the label wide enough to display the result. Hope this helps.

Upvotes: 1

Related Questions