0

Following the examples on https://developers.google.com/apps-script/guides/html/communication I cannot make the simplest example work when embedded in the sidebar for a spreadsheet. If I publish the script as web app and open the URL the server side function is correctly found and executed (i.e. how the example is supposed to work), but when I use the same html output in the sidebar the execution always fails. Is there a way to debug what is going on on the server or is there any steps one should take when using html service embedded in sidebar to make server side calling to work? As explained I am using the example directly from the help page and it still does not work.

[14-07-19 18:22:23:455 EEST] Starting execution
[14-07-19 18:22:23:486 EEST] Execution failed: We're sorry, a server error occurred.
                             Please wait a bit and try again. [0.0 seconds total runtime]

...when I use the doGet it works as expected

Any ideas or help would be greatly appreciated.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Peter StJ
  • 2,297
  • 3
  • 21
  • 29
  • Forgot to paste the output; [14-07-19 18:22:23:455 EEST] Starting execution [14-07-19 18:22:23:486 EEST] Execution failed: We're sorry, a server error occurred. Please wait a bit and try again. [0.0 seconds total runtime] - when I use the doGet it works as expected – Peter StJ Jul 19 '14 at 15:23
  • Could you share your code, or better yet a minimized version of it that displays the problem? Have you tried the same script in a different document? Have you tried a different sidebar script that communicates with server-side scripts? (Try [this one.](http://stackoverflow.com/questions/24773177/how-to-poll-a-google-doc-from-an-add-on)). – Mogsdad Jul 19 '14 at 15:34
  • https://gist.github.com/37fef6cb284fa07642fa - the whole code can be seen here. I am using the new spreadsheet app, have not tried it in other type of docs. I have tried it with dialog and sidebar (the same issue) and I have tried it with success/failure handlers and the problem is the same (as the output in the question). – Peter StJ Jul 19 '14 at 16:35
  • Ok, pulled your code from the gist, pasted it, ran the `onOpen`, opened the dialog from the *Utilities* menu, dialog popped up with only a title, log has a single entry: `[14-07-19 12:47:34:864 EDT] Received object`. That's a "works for me". Humor me; make a new spreadsheet, and put your script in it, and see if it works there. You could have a file that's in "Googhell". – Mogsdad Jul 19 '14 at 16:51
  • Changed code to use sidebar, worked there as well. – Mogsdad Jul 19 '14 at 16:55
  • Ok narrowed it down. I have imported a library in the script (experimental). When a library is added even if not used it breaks calls to server side function. After I removed the reference to the library it works. This seems like a bug, should I report it? – Peter StJ Jul 19 '14 at 20:28
  • Yes, report it on the issue tracker. But first, check whether you had any name collisions, e.g. if the library had function `openDialog` or `doSomething`. It would still be an issue, because of the differing behaviors in the two access methods, but an important detail. – Mogsdad Jul 19 '14 at 20:35
  • Reported: https://code.google.com/p/google-apps-script-issues/issues/detail?id=4201&thanks=4201&ts=1405853885 – Peter StJ Jul 20 '14 at 11:12

1 Answers1

0

Use:

Logger.log('my variable value: ' + myVariable);

to debug .gs code, then view the log. You viewed the Execution Transcript, so I could assume that you know about Logger.log(), but that might not be the case.

You can also "step through" .gs code. There is a little picture of a bug on the menu. It's often shown grayed out. And when it's grayed out, no matter what you do, you're not going to get the debug process to start. You need to select a function name from the drop down box first for the debug stuff to be available. You can click just to the left of a line number in the code editor, and a red dot should appear to add a break point. Your code will stop executing at the break point and wait for you to click an icon to run the next line, or skip a line, etc.

Alan Wells
  • 30,746
  • 15
  • 104
  • 152