Remove the web1.GET on both and try
it still exits me out of app. One time I saw a notification say "given URL is not valid"
Do You want to delete the row by web get request? (Scripturl) or by spreadsheet component?
I want to delete the row that has the chosen value (listviewer selection)
for ex: If I chose team A, then whatever row says "team A" would delete.
All the rows to be delete whichever col B has the text Team A?
I imagine that the text present in col B and in such case, in your existing codes pls add this and deploy it once again then through script url method delete it.
function deleteAllRowsByColumnB(dataArray, sheet) {
var values = sheet.getDataRange().getValues();
var toDeleteValue = dataArray[0][1]; // Extract Column B value (Index 1)
var deleted = false;
for (var i = values.length - 1; i >= 0; i--) {
if (values[i][1] === toDeleteValue) { // Check if Column B value matches
sheet.deleteRow(i + 1); // Delete row (1-based index)
deleted = true;
}
}
if (deleted) {
return ContentService.createTextOutput('All matching rows deleted successfully.');
} else {
return ContentService.createTextOutput('No matching row found.');
}
}
Or share your existing code in which i will make changes and give you
here you can see the data is in column B,
All rows are listed in listviewer too,
if user selected a certain team (for example, row4 Varsity girls soccer)
row4 would be deleted.
ok I will try code.
It seems you will be sending partials data, in such case you should try this code
function deleteAllRowsByPartialColumnB(dataArray, sheet) {
var values = sheet.getDataRange().getValues();
var partialText = dataArray[0][1]; // Extract the partial text from Column B (Index 1)
var deleted = false;
for (var i = values.length - 1; i >= 0; i--) {
if (values[i][1] && values[i][1].toString().includes(partialText)) { // Check if Column B contains the partial text
sheet.deleteRow(i + 1); // Delete row (1-based index)
deleted = true;
}
}
if (deleted) {
return ContentService.createTextOutput('Matching rows deleted successfully.');
} else {
return ContentService.createTextOutput('No matching row found.');
}
}
what do I do after the code is deployed
How do I use scripturl method to delete?
Is there any way to delete selected data without code?
After listview picking
Set web2url to script url?+partialText={ListViewSelection}
Call Web2.get
When web2 got text
If get response code =200
Then set notification to "Success"
function doGet(e) {
var sheet = SpreadsheetApp.openById("YOUR_SHEET_ID").getSheetByName("YOUR_SHEET_NAME");
var partialText = e.parameter.partialText; // Get partial text from the URL parameter
if (!partialText) {
return ContentService.createTextOutput("Error: No search text provided.");
}
var dataArray = [[null, partialText]]; // Format data for the delete function
return deleteAllRowsByPartialColumnB(dataArray, sheet);
}
Your sheet name is not Sheet1.
See the dump procedure for the real name.
You still need the proper credential file to do a component delete row.
(The Get Sheet block can work without it.)
By the way, this is how you prevent blank input:
I replace the AND with an OR.
(Besides lining the two clauses up for readability)