The script and the CRUD in the app is not designed that way . It requires at least an Id and content in the second column to work. Why would you want an empty row in a database?
That said, my example is just one way, you can of course change how the script and the app work to your liking
I wanted to change because when i clear a row (deleting a row) the number of rows on my Google sheet decrease so I wanna add it every time I clear one.
Sounds like you want it to behave like sqlite or sql, where even if you delete a record, the record id remains. This is possible but will result in many empty items being returned if you request the dataRange, or you may not get back all the data if a script stops at an empty cell.
The CRUD script was designed to mirror AI2 lists, in that if you delete a record all the ids below move up one, maintaining a contiguous dataset.
// deletes a single record (and its row) from sheet. Requires row index and col1 to match
else if ( fn == 'DELETE' ) {
var index = e.parameter.INDEX; //index in list
var col1 = e.parameter.COL1; // current/existing value of col1 - it could be replaced...
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("Existing record deleted");
}
with this:
// deletes a single record (and its row) from sheet. Requires row index and col1 to match
else if ( fn == 'DELETE' ) {
var index = e.parameter.INDEX; //index in list
var col1 = e.parameter.COL1; // current/existing value of col1 - it could be replaced...
var cols = sh.getMaxColumns();
for (var i = 0; i < rg.length; i++ ) {
if ( index != undefined && i == index && col1 == rg[i][0] ) {
var entRow = sh.getRange((parseInt(index)+1),2,1(cols-1));
entRow.clearContent();
}
}
return ContentService.createTextOutput("Existing record deleted");
}
Which will clear the data in the row apart from the index in column 1 (A)
As previoulsy mentioned, not sure how this might impact on the functionality of other elements of the script, or the list returns to the app.
Have you set up your service account and downloaded your credentials.json file, then uploaded this to your assets ? You won't be able to change a google sheet unless you do this.
What do you mean by GAS and i wanna add a blank row at the end of the spreadsheet everytime like
if the data in 2 row should be deleted it will delete the row and add a new row at the end of the sheet.
like do you mean in the sheet ? also just to confirm i want the data like do you see the row thats highlighted in the picture i want it in a way where i command the app to delete the specific value or id containing in the column A and it should delete the row and add a new blank row at the end of the sheet