Let me explane you, I just dis an aplication with a log in and save the data in a Spedsheet after that I did another screen and in this one there is a form where the users have to put their personal data but I can't read the data previosly charged I mean I can't validate the data as password, name, url.
Please show your relevant blocks, and why do you think you need an extension?
Hi, thanks for asking. I think that I need an extension cause in my opinion there isn't a solution for this but maybe I'm confuse. Give a time and I send you the blocks
first send the information like this
then when I try validate the information i do like this
but i can´t connect and read the information
Please show your google apps script (as text)
var ssId = "1-wa6iHJSkF50ir0tJ839lZmiDRYBNpo7018EEkBmU3Y";
function doGet(e) {
var accion = e.parameter.accion;
var columna2 = e.parameter.num;
var valores = e.parameter.valores;
var datos = buscar(accion, columna2, valores);
var respostaJSON = JSON.stringify(datos);
return ContentService
.createTextOutput(respostaJSON)
.setMimeType(ContentService.MimeType.JSON);
}
function buscar(accion, columna2, valores) {
var sh = SpreadsheetApp.openById(ssId);
var sheet = sh.getSheetByName("DataBase"); // Change "Sheet1" to the actual sheet name
if (accion === "contar") {
var numpreg = sheet.getLastRow() - 1; // Count all rows except the header row
var resultado = { "accion": "contar", "numpreg": numpreg };
return resultado;
}
if (accion === "anadir") {
var datos = valores.split(',');
sheet.appendRow(datos);
return { "accion": accion, "valores": datos };
}
if (accion === "consultar") {
var datos = sheet.getDataRange().getValues();
for (var i = 1; i < datos.length; i++) { // Start from the second row (excluding header)
var row = datos[i];
var num = row[0];
if (num == columna2) {
var resultado = {
"accion": "consultar",
"num": num,
"columna2": row[1],
"columna3": row[2],
"columna4": row[3],
"columna5": row[4],
"columna6": row[5],
"columna7": row[6]
};
return resultado;
}
}
}
return { "num": "" }; // Return an empty object if no match or unrecognized action
}
Yes, your script is the problem, you call return
before getting any data together.
hey, could you help me? cause I've copied it from a video but I don't understand a lot recently I started with programming...
I can have a look in detail in a couple of hours
okey. thanks a lot. Take your time
Have had a chance to look at things. Actually, there is not too much wrong with the google apps script, other than the naming of the sheet - it is not the spreadsheet name but the sheet name. This is why the script is failing.
Why have you put the spreadsheet in the bin ?
Most of the issues are with your blocks.
- You can use a web component to send values to the spreadsheet, not a webviewer. However, if you have a google apps script web app, why not use that to upload values to your spreadsheet?
- I cannot see your full script url, but you do not appear to be sending any of the parameters required?
- You also need to call the url in your web component with the Web1.GET block (another reason why it doesn't work)
You may want to look at this instead?