Delete single row GSheet

We are close but something is wrong somewhere. Here is an example that works!

SHEET

image

SCRIPT

function doGet(e) {
    var ss = SpreadsheetApp.openById(e.parameter.ID);
    var sh = ss.getSheetByName(e.parameter.SH);
    var rg = sh.getDataRange().getValues();
    var index = e.parameter.INDEX;  //index in list
    var col1 = e.parameter.COL1;  // current/existing value of Col1
    for (var i = 0; i < rg.length; i++ ) {
      if ( index != undefined && i == index && col1 == rg[i][0] ) {
        sh.deleteRow(parseInt(index)+1);
      } 
    }
    return ContentService.createTextOutput("Record deleted");    
   }

BLOCKS

SCREEN

AIA

deleteRow.aia (4.1 KB)

SHEET URL

Sharing set as a minimuim to anyone with the link. Here I have set to allow anyone to edit so you can test and reset the sheet.

Press the Read button to return the list on the sheet, and display this in the listview
Select an item in the listview to delete the item on the sheet, and update the listview

this is what you are returning, which does not make much sense...


Taifun

Ho importato il tuo progetto nelle mie tabelle e funziona tutto.
L'ultimo problema rimasto è se all'interno di una cella ci sono due parole con uno spazio in mezzo il procedimento da errore e non elimina quella determinata riga.
Come possiamo risolvere?


Se invece tra le parole scritte non ci sono spazi il tutto funziona correttamente.

Ho risolto il problema sostituendo lo spazione con l'underscore (_).
Ora funziona tutto a meraviglia.

Grazie infinite per l'aiuto.

Rettifico quello che ho detto prima.
Ora quando inserisco una nuova riga mi esce questo errore:
image

which means, there is an error in your csv table, see also this thread

Taifun

If you want a full CRUDQ (create,read,update,delete,query) with a google sheet, see here:

CRUD with Google Sheets, Web App and AI2

Why the script can't work? The error is CSV file.
I downloaded the aia file and the script. I replace the new script link into "globalscriptURL" but I can't find where to paste the paste link of the spreadsheet.

With that version the script automatically uses the first sheet in the spreadsheet.

If you want to name the sheet then you need to change every instance of:

var sh = ss.getSheets()[0];

to

var sh = ss.getSheetByName(e.parameter.SH);

remembering to republish your web app to a new version

and send a parameter &SH=Sheetname from your app (Sheetname being what ever the name of your sheet is, e.g. Sheet1)

Alternatively, you may want to look at:

or

ok, but where I paste the link of spreadsheet? (ex.: "https://docs.google.com/spreadsheets/d/......")

Also in that version, the script is bound to the spreadsheet. This means that a different script call can be used to get the spreadsheet:

var ss = SpreadsheetApp.getActive();

you will need to change this to:

var ss = SpreadsheetApp.openById(e.parameter.ID);

and send the spreadsheet ID as a parameter from the app

&ID=<SpreadsheetID>

Again this is handled by the two scripts found in the links I provided

Sorry, I try to use che CRUDQ II but i have this error:


I have replace the ID table and the link of script.
The issue is character "space" when I create or Update function.

The important bit of the html message is at the bottom!

You say

The issue is character "space" when I create or Update function.

Please explain what you are doing and show screenshots etc.. The script should accept fields with spaces, it certainly works for me.

if I try with the companion screen through my telephone it work but if I try with the emulator doesn't work.


Where I replace the name of columns into the script or the webapp?
I want to add and replace the field name.

You would do this in the spreadsheet

If you read the accompanying text, you will have noted that CRUDQII is setup for 10 fields (columns) only

Thanks for the help, I modified your block for my use and the system work fine.

I want to implement another function: Is it possible to perform mathematical operations between some numbers on different row?

If you placed the answer there it would make a mess of your dataset....you would add another row with just that data, that wouldn't correspond to the other records.

Can you store this on another sheet ?
Can you store this in the app ?

Yes, I can create another spreadsheet for only math operation with the same number of row. In this case function update recall row text into the spreadsheet posted up before. Is correct? How it made?
In case how can store in app?

I am sorry I do not understand what you want to do. Please explain with more words and pictures.

I am still not really sure why you want to add cells in a column?

(You do not have to use another spreadsheet, just add another sheet/grid to the same spreadsheet)