Cerca record personalizzati, inseriti su label, in un foglio google

posso agire con qualsiasi cosa da voi suggerito creando un SCREEN nuovo, non ho nessuna preferenza, questo lo sto chiedendo a voi, l'mportante è che si collega al mio Foglio GOOGLE "Carrello" e va a cercare sulla colonna "Email".. chiedo a voi una funzione apps script o altro...Nel foglio "CARRELLO" sto inserendo tutte le email di tutti i clienti, con altri campi eS: "Telefono", "Citta", ecc... Ogni cliente deve vedere solo i suoi inserimenti... spero di essere stato chiaro

You did not answer this...

io non capisco la tua domanda... in che senso come interagisci? Uso Mit 2 app inventor e un foglio di google..

and what do you use to create,read, update or delete data on the google sheet from AppInventor?

oppure cosi

OK, you are using google apps script.

Could I recommend this approach instead, which I believe is an improvement over the one you are using, with the bugs removed.

If I understand correctly, you want to search your google sheet data by email address of the user, and return only their entries ?

si, hai capito bene

You can insert this into your script:

//READ BY USER EMAIL
else if (e.parameter.func == "ReadByUser") {
  var ss = Spreadsheet.getActive();
  var sh = ss.getSheets()[0];
  var rows = sh.getDataRange().getValues();
  var userData = [];
  for (var i=0;i<rows.length;i++) {
    if (e.parameter.EMAIL == rows[i][0]) {
      userData.push(rows[i]);
  }
  return ContentService.createTextOutput(JSON.stringify(userData));
}

Assumes:

  1. You send a parameter EMAIL = users email from your app to the script, along with the other parameters needed e.g. func = ReadByUser
  2. That in your google sheet, the email addresses are in the first column

When the data is returned in responseContent, you must convert it back into an AI2 list using the JSONTextDecode block. You can then work with this list to populate your textboxes/labels.

Scusami m forse non sono stato chiaro a me non serve avere una lista di record da ricercare e poi mi da il risultato di quello che ho trovato a me serve visualizzare nella mia label una sola email e dopo mi dai il risultato di tutto quello che trova... è cosi difficile? si può avere un esempio?? Ho bisogno di un esempio concreto non so lavorare con le JSONTextDecode. gli esempi che trovo qui non riesco a riportarli nel mio progetto

You asked for and confirmed that this is what you wanted.

The script snippet I provided should do that based upon the email address sent to the script.

It can be as easy or as difficult as you want to make it :wink:

si puo avere un esempio semplice completo? chiedo solo questa cortesia...come faccio a fare questo passaggio? ...... "come si utilizza il blocco JSONTextDecode?

1 Like

grazie molto gentile :clap::clap::blush:

Pultroppo non sono riuscito a risolvere.. ti allego tutte le schermate per capire dov'è l'errore
image
image

Check your email parameters. EMAIL does not equal Email.

Ho provato anche questo ma non funzione, dov'è l'errore?

You do not appear to be sending an email address as a parameter ?

Sto provando in tutti i modi a dirvi che sono in gorsse difficoltà ed ho chiesto a tutti, se è possibile allegarmi un piccolo esempio completo di variabili e tutto (sia per la parte Blocchi che la parte apps script). Ho bisogno di fare la ricerca di EMAIL, tramite un campo inserito dall'utente. FAccio un esempio.. su una txc inserisco l'email "PINCO@GMAIL:COM", questa email deve essere cerca all'interno di un foglio google chiamato "Carrello" all'interno della colonna "EMAIL" dove ci saranno anche altre colonne.
Il risultato delle ricerca deve comprendere, su una listView tutti e solo i record inseriti dall'EMAIL "PINCO@GMAIL.COM". Grazie a tutti

OK, hopefully you will understand this example:

Spreadsheet data

image

Script

function doGet(e) {
  var ss = SpreadsheetApp.openById(e.parameter.ID);
  var sh = ss.getSheetByName(e.parameter.SH);
  var rows = sh.getDataRange().getValues();

  //READ BY USER EMAIL
  if (e.parameter.func == "ReadByUser") {
    var userData = [];
    for (var i=0;i<rows.length;i++) {
      if (e.parameter.EMAIL == rows[i][0]) {
        userData.push(rows[i]);
      }
    }
  }
  return ContentService.createTextOutput(JSON.stringify(userData));
}

Blocks

App Screen (after fetching records for 'pinco@gmail.com')

image

1 Like

Sei molto chiaro, grazie a te ho risolto. sei un grande