How to use a google sheet on AI2

Hi there,
I see lots of doubts about using google sheets as Data Base, and some other tutorials that i seen i don't worked, that way i decided to create this tutorial that explains how to use them. Note this tutorial don't talks about a full CRUD, just adding a new row.
Step 1: create a google sheet on your google drive and adjust it.



Step 2: open Tools >> Script editor to run google apps scripts and program the 3 functions: AddSheetDataRow(), doGet(), doPost().

Step 3: click publish >> deploy as web app on google apps scripts.
You need to set drop-downs like this:
deploy as web app
If you do Any change to the script, step 3 needs to be repeated, same values to drop-down menus
step 4: app inventor blocks
Drag a web component from connectivity, we will need it...
First, copy the URL from your apps script and use it as global variable.
An example aia:
Test.aia (3.8 KB)
That's it.
This solved your problem, helped you and worked?

  • Yes :+1:
  • No, improve this

0 voters

GuiM Hares

1 Like

Also see here:

HOWTO: Create a Google Apps Script Web App bound to a Spreadsheet

It was based on it, but it don't worked. Do you remember the topic "I have a doubt about the spreadsheet tutorial from puravidaapps" ? I am @GuiM_Haes !
So i adjusted it so that it works!

that tutorial uses a different method, a google form to submit data

Just saying that helps no-one. It probably didn't work for you because of an error somewhere in your code or blocks, or not setting the correct permissions.

I am not talking about that tutorial... I am talking about the topic, when It don't worked I visited your website it don't worked too so I decided to change the apps script and that way it worked

Just asking you to justify this, simply saying the example on my site doesn't work, without any additional information, when definitely it works well for many users, is a little unfair.....

(If it really doesn't work, then I need to know what doesn't work, so I can fix it, but as far as I am aware, after extensive testing and use, there is nothing wrong with my example)

The Sheet parameter from addUser don't worked with sheet variable, but worked using ss variable
When I talk about don't worked It is because a new row was not appened to the sheet
My blocks are like on the aia
my Google apps script is equals to your one, I just renamed the addUser function.

I believe you are referring to an older demo on my site, not the one in the link above. I have found that this does not work correctly, which arose sometime afterwards (was working), due to this issue (which shows a fix):

https://www.metricrat.co.uk/google-apps-script/return-output-from-function-call-in-doget

(I will update the older topic to reflect this)

Everything explained, I was referring me to that old tutorial :smile:
My one also works well, I tested it. So, just multiple ways :grinning: