Hello, I want to update the values of a row in a Google Sheets spreadsheet based on a specific value located in the 7th column on Google Sheets. I've used the following script, but after execution, it displays the response "Update successful" while nothing gets updated. Can you please assist me? Thank you.
my script:
function updateRowByColumnValue(e) {
var ss = SpreadsheetApp.openById('1mgWiNwNhKfI64ZWOvaGPKIgxC6jiQ620tjH7-27V3bQ');
var sh = ss.getSheetByName('cross');
var columnNumber = 7;
var gValue = e.parameter.G;
var lr = sh.getLastRow();
for (var row = 1; row <= lr; row++) {
var data = sh.getRange(row, columnNumber).getValue();
if (data == gValue) {
var b = e.parameter.B;
var c = e.parameter.C;
var d = e.parameter.D;
var eValue = e.parameter.E;
var fValue = e.parameter.F;
var hValue = e.parameter.H;
sh.getRange(row, 2).setValue(b);
sh.getRange(row, 3).setValue(c);
sh.getRange(row, 4).setValue(d);
sh.getRange(row, 5).setValue(eValue);
sh.getRange(row, 6).setValue(fValue);
sh.getRange(row, columnNumber).setValue(gValue);
sh.getRange(row, 8).setValue(hValue);
Logger.log('Ligne mise à jour avec succès');
return ContentService.createTextOutput('Mise à jour effectuée avec succès');
}
}
Logger.log('Aucune ligne correspondante trouvée');
return ContentService.createTextOutput('Aucune ligne correspondante trouvée');
}
// Exécutez la fonction lorsque la requête provient d'App Inventor avec func=UPDATE
function doGet(e) {
if (e.parameter.func === 'UPDATE') {
return updateRowByColumnValue(e);
} else {
return ContentService.createTextOutput('Fonction non valide');
}
}