Writing in a google sheet

Hello !

I have achieve to put datas into a goggle sheet through a google form so if anyone need help, just see below :

Web tutorial : Tuto by Allison John ( thanks to her ).

My job :

You know we can’t read the text in the … at the end of the text blocks?

To solve that, break the long text up and JOIN the short pieces,
to make everything visible that should be visible.

Considerate authors do individual Download Blocks as Image operations on individual blocks, to get draggable blocks that can be pulled into readers’ Blocks Editor sessions.

Looks like the spreadsheet example by @Taifun

More like this:

https://ai2.metricrat.co.uk/guides/use-ai2-to-directly-submit-google-form-data

1 Like

Yes you’re rigth !

I had not find any example so … :slight_smile:

TIMAI2 : you link gives an easiest way to do it. ==> Thank you

1 Like

Hello. I have tried to adapt your example but something must be wrong in my work.

image

I changed the end of the script url with /exec

Adaptation of your script :

function doGet(e) {
var ss = SpreadsheetApp.openByUrl(“https://docs.google.com/spreadsheets/d/1NYkQdZc32elE4GlCLUN3M77RMYEv2hchmtfXxzMKra0/edit#gid=0”);
var sheet = ss.getSheetByName(“Sheet1”);

addUser(e,sheet);
}

function doPost(e) {
var ss = SpreadsheetApp.openByUrl(“https://docs.google.com/spreadsheets/d/1NYkQdZc32elE4GlCLUN3M77RMYEv2hchmtfXxzMKra0/edit#gid=0”);
var sheet = ss.getSheetByName(“Sheet1”);

addUser(e,sheet);
}

function addUser(e,sheet) {
var id = e.parameter.id ;
var name = e.parameter.name ;

sheet.appendRow([id,name]);

}Exo_Ecrite_SpreadSheet.aia (1.9 KB)

Change the above to:

function addUser(e,sheet) {
var id = e.parameter.Nom ;
var name = e.parameter.Prenom ;
1 Like

Hello.

I changed my way to check by doing exactly what you advise us to do on the web page :

Here is what i write in the scrpit url adding exec at the end : https://script.google.com/d/1UTv-ZvIWw-114nmoM3UynlIO8cJRt55B_thfGErl3sc3qRbKCGTlu83J/exec

Then that gives :

The script and sheet are open to any one :

image

and it is not runing properly.
There is surely something wrong in my copy :frowning:

If i try to un derstand the scprits :

  • the two fisrt function ( doGet(e) and doPost(e) have the same content
  • addUser : adds a row with the parametrers from AI2 id= and name=

Have you republished your web app script to a new version ? Try it.

The web app ( the script ) must be integrated to the sheet i want to use or must they be separated ?

image

what do you mean by republuish ? I am directly working on a webpage and not on a file in my computer

The way you have coded in your script, this doesn't matter. Assuming that you have a standalone script project: "CopyDataTest":

1 Open the script project
2 Go to Publish
3 Deploy as Web App
4 Project version: - select New from the dropdown
5 Execute the app as: your google account address (email)
6 Who has access to the app: Anyone, even anonymous
7 Press the Update button

You have to do this EVERY TIME you change your script

OK ! It is running properly.

It was my first time on google scripts so … I am not used to its use.
So I must learn how to use it and how to do some scripts by my one !

If I could advise you something : you should add to your web page what you told me to do ( publishing the the sript ) it wasn’t clear for me. Peerhaps only with a screenshot !

For you information : I am doing a small app for my club to store data about some skiing, moutainering hikings.

THANK YOU !!! :+1: :+1:

RTM :slight_smile:

Hello TIMAI2.

Now I want to add a new columln but I want to chek everything step by step so first i changed the name of the I/O as shown in the image below :

I have republished the script.
When running the APP blocks only the second value is transfered ( name ) but not the first one ( date ) .
Could you explain me why ?

If the second one has been transferd it means that the script has been published correctly. No ?

If Yes it means that the modification of the I/O names is not correct but I dont see why …

You might need to encode your date format

blocks (7)

this also works for international characters such as accents, egrave, umlaut, etc.

Hello !
I have my answer :slight_smile:

As I was writing you that message i had the idea that the publishing was wrong and it WAS : I have to set new version when publishing !

I assumed you had already learnt that lesson!

However, the encodeUri block is another useful tool when posting or getting data with google sheets.

The modification of the I/O name is ok now : :+1:

If I need to send more than 2 values I need to :

  • modify the script
  • publish the script as a new version
  • modify the blocks

==> correct ?

image

And put the headings in the columns on the spreadsheet

naming a new column done :
image

I think the execution problem I have is because of the the rights I give to the execution

image

I say so because evene if i change the code inside thescripts with the code that is running properly on other scripts this is not running correctly so …