I have this function that resets my form. But I would like to delete all questions except the first one, so that the item ID and entry of this question remain fixed within a dynamic pre-filled link. Note : the number of questions following the fist one varies, which is why I cannot point at the item IDs directly.
function resetform() {
var form=FormApp.openById(FORM_ID)
var items=form.getItems()
items.forEach(item=>form.deleteItem(item))
//1994309330 ==> the Item ID that I would like to keep in the delete process
}
Is there a way I can delete all items except item ID 1994309330 ?
I tried to replace items.forEach(item=>form.deleteItem(item))
by items.forEach(item !=1994309330 form.deleteItem(item))
but it does not work
I believe your goal is as follows.
1994309330
.In this case, how about the following modification?
Please set your form ID to FORM_ID
.
function resetform() {
var form = FormApp.openById(FORM_ID);
var items = form.getItems();
items.forEach(item => {
if (item.getId() != 1994309330) {
form.deleteItem(item);
}
});
//1994309330 ==> the Item ID that I would like to keep in the delete process
}
1994309330
are deleted.