0
votes

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.

1
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 expectedPeter StJ
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.).Mogsdad
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
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
Changed code to use sidebar, worked there as well.Mogsdad

1 Answers

0
votes

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.