I have a school data where there are more than 300 students in diffrent classes now I have to create a register using Google form. So i created a google form with option asGridItem. With column as present and absent and set its Row as student admission no. From my spreadsheet but the problem is I have to update this row such that if a new student get added in that spreadsheet google form update itself. but the problem is with my code it doesn't edit the spreadsheet but the code set another value and deleted the previous one which mess up my response that I don't want. I want to edit that existing row and add the new student or delete that student from the Form row and not edit my entire form.
function edit() {
var form = FormApp.openById("formid");
var class1 = form.getItemById("itemid").asGridItem();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("sheetname");
var val = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getlastcolumn()).getValues();
var filter = val.filter(r => { return r[0].toString() === "1" }).map(t => t[2]);
class1.setRows(filter);
}
this is the code it give response as
1 2 3
but when I add '4' to spreadsheet it will give response like this ->
1 2 3
1 2 3 4
But I don't want my response to look like that I want my response to look like this->
1 2 3
1 2 3 4
Start from begning again not from the bottom and yes I have checked all the other question which is similar to mine but no none of them giving me the response sheet that I want.