How to delete selection in listviewer w/ Sheets

Hi! I am trying to delete data that I selected off the listviewer I created. Everytime I try with different code blocks, the app crashes. Is there any way to do such an action without app scripting the google sheet? This is the code I have right now. If a user selects a certain team, it gives them the option to delete. I want the entire row of chosen data to be erased from Google sheet if possible. Please help!



^ These (2) blocks load the created teams on the listviewer

This is the .aia
HomeBase_copy (3).aia (257.1 KB)
The screen I am having trouble with is COACHcalendar

Please help! How can I code to delete chosen data? Preferably no scripting with Google sheets.

You can't delete using the Spreadsheet delete block without having the spreadsheet component's JSON Credential security file in place.

Your json file contains some users' names and email addresses, and does not qualify .

You also need

Dear samcho, you will need to use Apps Script to meet your requirement. If you are not familiar with how to deploy apps script and complete setup, you can watch the tutorial in this thread - [PAID $15] Google Spreadsheet Extension Pack With/Without Image Hosting (An Alternative To Airtable) - #44 by eAcademy

1 Like

I did everything up until function doGet. How do I add that and what var sheet = to?

Do you use any appsscript? If ao provide us, let me explain you else you will struck again and again at the same

Share your comple apps script, you may remove the sheet id and sheet name

I have not created any appscript yet, this is all I have put.



^ The Google sheet

No issue. Then copy paste the above code in which just use the google sheet id and your google sheet name then deploy with access by anyone

Then in app just add script url as like i said earlier and try to pick a item from listview

Hi unfortunately I am trying to avoid extensions because they are not compatible with IOS, and I am using my phone for AI companion to test my app.

So I copy and paste everything after "Success"?

Is this format right?

It does not let me deploy my script because my spreadsheet ID is underlined red.

Pls use hyphens at the begining and the end like this

"sheetID"

OK and keep parenthesis?

Your code is wrong

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 deletedRows = deleteAllRowsByPartialColumnB(partialText, sheet);
    return ContentService.createTextOutput("Deleted Rows: " + deletedRows);
}

function deleteAllRowsByPartialColumnB(partialText, sheet) {
    var data = sheet.getDataRange().getValues(); // Get all data
    var deletedCount = 0;

    for (var i = data.length - 1; i >= 0; i--) {
 // Loop from bottom to top
        if (String(data[i][1]).includes(partialText)) { 
// Check if column B (index 1) contains the text
            sheet.deleteRow(i + 1); 
// Delete the row (1-based index)
            deletedCount++;
        }
    }

    return deletedCount;
 // Return number of deleted rows
}

Ok I will fix

deployed. Anything else I need to do? Are my code blocks right

Nope. I have updated the code, pks copy paste and deploy again.

Copy the url (this is called script url)

Now in blocks side

When list view after picking
Set web url to {your copied script url +? + partialText +listview selection

Is this correct?

Perfect but add = symbol after the partialText

and I still keep this code block?