Javascript to send Data to Google sheets

Lua Shixiong shared this question 1 year ago
Answered

Dear all in GGB community,

I am so close to materialize an idea of mine to send data from an applet to Google sheets. With the data in sheets, I could better monitor responses (perhaps Geogebra classroom may eventually be able to do this) and to link it to flippty where I could award badges.

I have been diligently following this tutorial: https://www.geogebra.org/m/uhsmpcpe but after following the instructions, changing header of the google sheet and making sure the Javascript matches the headers, I am getting an Reference Error sendData is not defined error after clicking on the SEND button.

Michael and Lewws has previously given me some hints. I have followed them but again met with other errors.

Can anyone help?

Providing the links to the google sheet:

https://docs.google.com/spr...

and GGB aaplet:

https://www.geogebra.org/m/dhjvmhbp


Many thanks in advance!

Comments (3)

photo
1

I suggest you start again from the working version and make small change -> test -> make small change -> test -> etc

photo
1

Hi Lua,

I was curious what happened above and did a thorough check.

Initially I was not able to detect what was wrong.

I can confirm your ggb file coding is in order.

However your Google spreadsheet set up could be faulty.

I have copied your resource and put it at https://www.geogebra.org/m/jtd4mphh

I cloned 2 spreadsheets (from my own successful Geogebra to Google Sheet recordings)

They are at

1. https://docs.google.com/spreadsheets/d/1a1eu66glUs4Oedn7nNzD6xWqy8oqUDGPH8Kb6XKR1fs/edit?usp=sharing

2. https://docs.google.com/spreadsheets/d/1-llt-UL0cor1Kuo8s5XRBT-4-peAwLrS6lif7K3YNOk/edit?usp=sharing

In each case, I go through the rest of the setup procedure outlined in https://www.geogebra.org/m/uhsmpcpe minus the recommended coding from the web page, but using the coding from my successful files.

ie. I run "setup", deploy the code as "webapp" and Execute as "me .....email address" and Who has access as "any one"

d0228d8241300cf9487a3530afc9670a

Each file after running setup and "deploying" it, you will be able to get the web app url for each spreadsheet.


Using your ggb file, under Global Javascript tab, for scriptURL

for sending data to the first spreadsheet 1.

the scriptURL to be pasted is https://script.google.com/macros/s/AKfycby-ihDJpIAmSpNcDgKH9lpZcJBkPMtGrco4kGbRfVfSgHToTb39rdJt6NohfHi7LvCX/exec

for sending data to the second spreadsheet 2

the scriptURL to be pasted is https://script.google.com/macros/s/AKfycbzC66XyHDEEipIUki4K-ytdLkD0y9mu6plTImLYkvfPplCTUDv7dgmjDn8oBa8nciHd/exec

If you want to try sending data from your own Geogebra resource, use any of the two scriptURLs (paste one at a time). After updating, upload to your online resource https://www.geogebra.org/m/dhjvmhbp , try to send data from there, and then view the corresponding spreadsheets.

I suggest you keep a copy of successful spreadsheets, then duplicate them and run setup and then finally get the scriptURL for your own resource.


Regards,

lewws

photo
1

Hi Lua,

Your remark that "I am getting an Reference Error sendData is not defined error after clicking on the SEND button." is due to the fact that you cannot run the Global JavaScript codes in the ggb file on your desktop.


The Global JavaScript codes work only when you run a Geogebra file online using a web browser.

Hope these help you

photo
© 2021 International GeoGebra Institute