Besoin d'aide pour modifier les données dans googlesheet

bonjour, je n'arrive pas à modifier les données que j'ai envoyé dans la googlesheet, quelqu'un peut m'aider ?
voilà mes blocs :

voilà mon script :

function doGet(e) {
 
  var ss = SpreadsheetApp.openById('1BSUDHn08h6YlrtgfeoQEVhjdvNp3rGPxZiTVq9r-bSY');
  var sheet = ss.getSheetByName("Sheet1"); 
  var sh = ss.getSheetByName("Sheet2"); 
  var nom = e.parameter.nom ; 
  var motdepasse = e.parameter.motdepasse ;
  var msg;


  if ( e.parameter.func == "register" ) { 
    sheet.appendRow([nom,motdepasse]);
    return ContentService.createTextOutput("Nouveau compte"); 
  } 
  
  else if ( e.parameter.func == "testLogin" ) {
    var msg = "Information incorrecte";
    var loginData = sheet.getDataRange().getValues();
    for ( var i = 0; i < loginData.length; i++ ) {
      if ( nom == loginData[i][0]  && motdepasse == loginData[i][1] ) {
        msg = "connecté";
    }
  }
    return ContentService.createTextOutput(msg);

    
  }

  else if ( e.parameter.func == "supprimer" ) { 
   var loginData = sheet.getDataRange().getValues();
   for (var i = 0; i < loginData.length; i++ ) {
   if ( nom == loginData[i][0]  && motdepasse == loginData[i][1] ) {
        msg = "compte supprimé";  
        sheet.deleteRow(i+1);
    }
   }
   var reportData = sh.getDataRange().getValues();
   for (var i = 0; i < reportData.length; i++ ) {
     if ( nom == reportData[i][0] ) {
          msg = " compte supprimé";  
          sh.deleteRow(i+1);
     }
   }
   return ContentService.createTextOutput(msg);
    }
  

   if (e.parameter.func == "WriteReadReport") { 
    var nom = e.parameter.nom ;
    var date = e.parameter.date ;
    var repas = e.parameter.repas ;
    var change = e.parameter.change ;
    var sieste = e.parameter.sieste ;
    var soins = e.parameter.soins ;
    var photo1 = e.parameter.photo1;
    var photo2 = e.parameter.photo2;
    var transmission = e.parameter.transmission ;
    sh.appendRow([nom,date,repas,change,sieste,soins,photo1,photo2,transmission]);
    SpreadsheetApp.flush();
    var ref = [    ];
  var rg = sh.getDataRange().getValues();
  for (var i=0;i<rg.length;i++) {
    if (rg[i][0] == nom) {
      ref.push(rg[i][0]);
      ref.push(Utilities.formatDate(rg[i][1],Session.getScriptTimeZone(), 'dd-MM-YYYY'));
      ref.push(rg[i][2]);
      ref.push(rg[i][3]);
      ref.push(rg[i][4]);
      ref.push(rg[i][5]);
      ref.push(rg[i][6]);
      ref.push(rg[i][7]);
      ref.push(rg[i][8]);
    }
  }

  return ContentService.createTextOutput(JSON.stringify(ref)).setMimeType(ContentService.MimeType.JSON);

  }

  if (e.parameter.func == "Read"){
     
  SpreadsheetApp.flush();
    var ref = [    ];
  var rg = sh.getDataRange().getValues();
  for (var i=0;i<rg.length;i++) {
    if (rg[i][0] == nom) {
      ref.push(rg[i][0]);
      ref.push(Utilities.formatDate(rg[i][1],Session.getScriptTimeZone(), 'dd-MM-YYYY'));
      ref.push(rg[i][2]);
      ref.push(rg[i][3]);
      ref.push(rg[i][4]);
      ref.push(rg[i][5]);
      ref.push(rg[i][6]);
      ref.push(rg[i][7]);
      ref.push(rg[i][8]);
    }
  }

  return ContentService.createTextOutput(JSON.stringify(ref)).setMimeType(ContentService.MimeType.JSON);  
}

else if (e.parameter.func == "Modifier"){
  var data = JSON.parse('[' + e.parameter.DATA + ']');
sh.getRange(parseInt(e.parameter.nom) + 1,1,1,data[0].length).setValues(data);

return ContentService.createTextOutput("OK");
}
  
}

nom = text, for example "Agnes" - you cannot easily parse this to an integer (parseInt(nom))
You need to set the ROWID (row number) for this.

comme ça

else if (e.parameter.func == "Modifier"){
var data = JSON.parse('[' + e.parameter.DATA + ']');
sh.getRange(parseInt(e.parameter.ROWID) + 1,1,1,data[0].length).setValues(data);

return ContentService.createTextOutput("OK");

Yes, if following the example project, you will have downloaded some or all of the data on the spreadsheet and put it in a listview, which when you make a selection will return a selectionIndex, equal to the rowid (row number) you need.

Alternatively you can do much the same in your apps script (but remember to add 1, because javascript arrays start at 0 and not 1.)

je n'utilise pas de liste dans mon application , ni de sélection. Il faudrait que j'appelle (comme pour lire) les données déjà écrite de la sheet en cliquant sur le bouton et que je les modifie , est ce que c'est possible comme ça ?

As I said you can do it with your apps script, but you will need a column in your data that has unique values for it to work completely.

Let us say that the nom column has unique values, and nom is the first column of data in your sh (Sheet2), as an example.

In your script, after setting the spreadsheet and sheet (Sheet2), get the range values:

// put these with your other variables at the top of the script
rng = sh.getDataRange().getValues()
var rowid;

then iterate over the values for the nom column until you find a match, then you can get the rowid (row number) from the matched record.

// put this at the top of your Modifier section
// 0 is the first row, 1 is the second row, and so on...
for (var i=0;i<rng.length;i++) {
  if ( e.parameter.nom == rng[i][0] ) {
    rowid = (i+1);
  }
}

You then use rowid to replace the data in your Modifier section of the script

sh.getRange(parseInt(rowid) + 1,1,1 ...

oui c'est ce que je veux faire avec la colonne "nom" , je l'avais mis dans la ligne (parseInt(e.parameter.nom) au début mais c'était faux .
ok je vais corriger mon script avec vos informations.

pouvez vous me dire si le script est correct ?

else if (e.parameter.func == "Modifier"){
  rng = sh.getDataRange().getValues()
  var rowid;
  for (var i=0;i<rng.length;i++) {
  if ( e.parameter.nom == rng[i][0] ) {
    rowid = (i+1);
  sh.getRange(parseInt(rowid) + 1,1,1,data[0].length).setValues(data);
    }
  }
}

Why do you ask, does it not work ?

je n'est pas encore modifié mes blocs , c'était juste pour savoir si le script était correct pour continuer

You appear to have left out the setting and parsing of "data"

var data = JSON.parse('[' + e.parameter.DATA + ']');

oui j'avais oublié, merci.

j'ai essayé de placer les blocs mais ça ne fonctionne pas.
J'ai mis le contenu de la réponse dans le label "modifprenom11" et je retrouve toutes les données dans le label alors que que je veux que chaque donnée soit dans leur label pour pouvoir les modifier par la suite, et quand j'enlève le label je n'est plu de données, pouvez vous m'aider à corriger les blocs.

Does func=Modifier or func=Edit in your script ?

oui voilà func=Modifier

else if (e.parameter.func == "Modifier"){
rng = sh.getDataRange().getValues()
var rowid;
var data = JSON.parse('[' + e.parameter.DATA + ']');
for (var i=0;i<rng.length;i++) {
if ( e.parameter.nom == rng[i][0] ) {
rowid = (i+1);
sh.getRange(parseInt(rowid) + 1,1,1,data[0].length).setValues(data);
}
}
}

voilà func=writeReadReport

if (e.parameter.func == "WriteReadReport") {
var nom = e.parameter.nom ;
var date = e.parameter.date ;
var repas = e.parameter.repas ;
var change = e.parameter.change ;
var sieste = e.parameter.sieste ;
var soins = e.parameter.soins ;
var photo1 = e.parameter.photo1;
var photo2 = e.parameter.photo2;
var transmission = e.parameter.transmission ;
sh.appendRow([nom,date,repas,change,sieste,soins,photo1,photo2,transmission]);
SpreadsheetApp.flush();
var ref = [ ];
var rg = sh.getDataRange().getValues();
for (var i=0;i<rg.length;i++) {
if (rg[i][0] == nom) {
ref.push(rg[i][0]);
ref.push(Utilities.formatDate(rg[i][1],Session.getScriptTimeZone(), 'dd-MM-YYYY'));
ref.push(rg[i][2]);
ref.push(rg[i][3]);
ref.push(rg[i][4]);
ref.push(rg[i][5]);
ref.push(rg[i][6]);
ref.push(rg[i][7]);
ref.push(rg[i][8]);
}
}

return ContentService.createTextOutput(JSON.stringify(ref)).setMimeType(ContentService.MimeType.JSON);
}

OK, you are sending data in the wrong way. This needs to be in a list / json array.

I do actually show how it is done here:

but it is perhaps not obvious what is happening.

I can provide you with an example, but it will have to be tomorrow.

Here is how it should be:

image

j'ai modifié les blocs comme votre exemple mais c'est pareil j'ai toutes les données dans le même label ! est ce qu'il faut que je modifie le bloc web1 que j'ai mis plus haut (au niveau des traits bleu) ? je suis perdu

Your words do not explain or show where your problem lies.

Relevant blocks ?
Output from script (responseContent) ?
Changes, if any, to the google sheet / target rrecord ?

If you do not show what is happening / which part is not working, it is difficult to help.

ah oui désolé, avant de montrer mes blocs j'ai une question , est ce que on peut écrire (qui envoie les données dans la sheet)/lire et modifier les données avec le même bouton ?

Do you want to read the existing data before modifying it, or after modifying it.

In any case, I suggest you just do one thing at a time, get that one thing working, then expand on what you want to do. You already have script that reads the data.