Kodular to google sheets

Hi all. Im busy writing an app to log work hours to google sheets but struggling to write to different sheets,

Here is part of the blocks:

and here is the script:

function doGet(e) {

  • var ss = SpreadsheetApp.openByUrl("**************************");

  • var sh = ss.getSheetByName(“Francois”);*

  • addUser(e,sh);*

}

function doGet(f) {

  • var ss = SpreadsheetApp.openByUrl("*****************");

  • var sheet = ss.getSheetByName(“Wimpie”);*

  • addUser(f,sheet);*

}

*function doPost(e) { *

  • var ss = SpreadsheetApp.openByUrl("***************************");

  • var sh = ss.getSheetByName(“Francois”); *

  • addUser(e,sh);*

}

*function doPost(f) { *

  • var ss = SpreadsheetApp.openByUrl("*****************************");*

  • var sheet = ss.getSheetByName(“Wimpie”); *

  • addUser(f,sheet);*

}

function addUser(e,sh) {

  • var F_Date= e.parameter.F_Date ; *

  • var F_Time_In= e.parameter.F_Time_In ;*

  • var F_Time_Out= e.parameter.F_Time_Out ; *

  • var F_Location= e.parameter.F_Location ;*

  • var F_Total_Time= e.parameter.F_Total_Time ;*

  • sh.appendRow([F_Date,F_Time_In,F_Time_Out,F_Location,F_Total_Time]);*

}

function addUser(f,sheet) {

  • var W_Date= f.parameter.W_Date ; *

  • var W_Time_In= f.parameter.W_Time_In ;*

  • var W_Time_Out= f.parameter.W_Time_Out ; *

  • var W_Location= f.parameter.W_Location ;*

  • var W_Total_Time= f.parameter.W_Total_Time ;*

  • sheet.appendRow([W_Date,W_Time_In,W_Time_Out,W_Location,W_Total_Time]);*

}

So both the URL are correctly inputted. Can anyone check if the script are correctly or how can i change the app blocks to specify the sheet names

Do you want to send to one sheet or multiple sheet?

Instead of using script method you can use this simple method

By using google form method we will send datas to gsheet

I have 2 screens on the app. the one must write to the one sheet “Francois” and the other screen to “Wimpie”

That is not an issue. But at a time single script won’t write into multiple sheet.

Per script URL per sheet only possible

You cannot have more than one doGet() or dopost() in your web app - how will the script know which one to run ?

I suggest you set your getSheetByName as a parameter, and send this from the app to the script:

e.g. ?ID= asjfhas…lfijsf&sheet=Francois

and in your script:

var sh = ss.getSheetByName(e.parameter.sheet);

See also:

1 Like

Instead use two web component and two script url at a same time.

BTW why do you have to send same data to multiple sheet? Why don’t you use simple formula into the sheet2 there by if sheet1 got data’s