How do you Delete the data Spreadsheet using app Script?

You deleted the app script url block

where is deleted

You have also deleted the global variable dataset

For the Clear_Record response you need blocks to be like this:

image

because of:

return ContentService.createTextOutput("Success, Record Deleted");

maybe I need to add web to web 2 because web1. GoText is used

No, you can include an if/else statement and use a variable to set which call you are making to the app script. Get the Delete method working first!

I'm so confused. may you show me all you want.

1 Like

oke thank you that is work? i hope you try too to get the specific problem.

r u get it?

I am not testing, because i would then have to set up a sheet and a script to do so. You test, and report back the results. I can't test yours, because as I said, you did not provide the script url or the sheet url.

the result is still error

You Used the script?

What error ?

like this . still error like this

when I clicked the button

The Clear_Record button ?

the both of button.

Try these blocks and the script below:

function doGet(e) {

  //READ ALL RECORDS
  if ( e.parameter.func == "ReadAll") {
    var ss = SpreadsheetApp.openById(e.parameter.ID);
    var sh = ss.getSheetByName(e.parameter.SH); 
    var rg = sh.getDataRange().getValues(); 
    
    return ContentService.createTextOutput(JSON.stringify(rg));
  }
  
   //DELETE SINGLE RECORD
   else if (e.parameter.func == "Delete") {
    var record = e.parameter.id;
    var ss = SpreadsheetApp.openById(e.parameter.ID);
    var sh = ss.getSheetByName(e.parameter.SH); 
    sh.deleteRow(parseInt(record) + 1);  
    return ContentService.createTextOutput("Success, Record Deleted");  
  }
}

1 Like

thanks that was also a solution for my problem