//UPDATE SINGLE RECORD
else if (e.parameter.func == "Update") {
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[0];
var data = [ [ e.parameter.name, e.parameter.id ] ];
sh.getRange("B"+(parseInt(e.parameter.id)+1)+":C"+(parseInt(e.parameter.id)+1)).setValues(data);
return ContentService.createTextOutput("Success");
}
If your update has worked on the apps script and spreadsheet then your responseContent = "Success"
Obviously you cannot convert this to a list
When you get such an error you should be using Do It to see what is happening, or putting your responseContent to a label to see what is coming back. Basic debugging, and quicker than having to keep asking questions.
you have confused with GET request, Make sure Are you using only one GET request or multiple.? If multiple then in the web request you cannot handle like this.
Every Action words you should use one if condition. As per your block, update action request will throw only Success as a text output. In such case how can you make list items?
Based upon what you are sending from your app the above should be changed to:
var ss = SpreadsheetApp.openById(e.parameter.ID);
var sh = ss.getSheetByName(e.parameter.SH);
Everything else looks OK...
Depending on the content of your textboxes (is it in Arabic/Persian etc.), you may need to use the Web component's UriEncode block on the texbox.text...
function ManageSheet(e) {
// READ ALL RECORDS
if (e.parameter.func === "ReadAll") {
var sheetId = e.parameter.sheetId; // Get the sheet ID from the request
var ss = SpreadsheetApp.openById(sheetId); // Open the sheet by ID
var sh = ss.getSheets()[0]; // Assumes you're working with the first sheet
// Get all data in the sheet
var data = sh.getDataRange().getValues();
// Return the data as JSON for ListView
return ContentService.createTextOutput(JSON.stringify(data))
.setMimeType(ContentService.MimeType.JSON);
}
else if (e.parameter.func == "Delete") {
var record = e.parameter.id;
var sheetId = e.parameter.sheetId; // Get the sheet ID from the request
var ss = SpreadsheetApp.openById(sheetId); // Open the sheet by ID
var sh = ss.getSheets()[0]; // Assumes you're working with the first sheet
sh.deleteRow(parseInt(record) + 1);
return ContentService.createTextOutput("Success");
}
// UPDATE SINGLE RECORD
else if (e.parameter.func == "Update") {
var ss = SpreadsheetApp.openById(e.parameter.ID);
var sh = ss.getSheetByName(e.parameter.SH);
var data = [
[
e.parameter.name,
e.parameter.cusid,
e.parameter.address,
e.parameter.accnum,
e.parameter.pymmthd,
e.parameter.memb,
e.parameter.date,
e.parameter.day
]
];
sh.getRange("B" + (parseInt(e.parameter.id) + 1) + ":I" + (parseInt(e.parameter.id) + 1)).setValues(data);
return ContentService.createTextOutput("Success");
}
}
and your script normalised for all three functions...
function doGet(e) {
var ss = SpreadsheetApp.openById(e.parameter.ID); // Open the sheet by ID
var sh = ss.getSheetByName(e.parameter.SH);
// READ ALL RECORDS
if (e.parameter.func == "ReadAll") {
var data = sh.getDataRange().getValues();
return ContentService.createTextOutput(JSON.stringify(data))
.setMimeType(ContentService.MimeType.JSON);
}
// Delete single record
else if (e.parameter.func == "Delete") {
var record = e.parameter.id;
sh.deleteRow(parseInt(record) + 1);
return ContentService.createTextOutput("Success");
}
// UPDATE SINGLE RECORD
else if (e.parameter.func == "Update") {
var data = [
[
e.parameter.name,
e.parameter.cusid,
e.parameter.address,
e.parameter.accnum,
e.parameter.pymmthd,
e.parameter.memb,
e.parameter.date,
e.parameter.day
]
];
sh.getRange("B" + (parseInt(e.parameter.id) + 1) + ":I" + (parseInt(e.parameter.id) + 1 )).setValues(data);
return ContentService.createTextOutput("Success");
}
}
now provided him with doPost code , also the sheet contains anyone editor option and many users are mishandled it so the deploy is not function properly. His script code doesnot contain doGet(e) too. now everything fixed