How to add a Form response to the Form as a checkbox item.
Important notes:
* This can be done from the Form script editor itself, rather than the Sheet
* The trigger must be installed
* The steps are important: Get the correct item, cast it to the correct item type, get all current choices, push the new choice into the array, set the array as the choices for the item
The editable form cannot be shared.
Form:
https://docs.google.com/forms/d/e/1FAIpQLSeYGJTtGdnFUpXhzrjyX0aWlMD88oGYP5At9U0X9l8z9pSozw/viewform?usp=sf_link
Sheet (to copy from File then “Make a copy”):
https://docs.google.com/spreadsheets/d/1ms80LYR-yrPFFlpZy62Uz9Xw1IgdpUqF4d7FTZeCsWU/edit
Script:
function addNewChoice(e) {
let form = FormApp.openById(“1mBzV2NdfGMb82VCg_Dfx9pasl77bGuCkXTRc1Xya6FE”);
let check = form.getItems(FormApp.ItemType.CHECKBOX)[0].asCheckboxItem();
let inChoices = check.getChoices();
let outChoices = [];
for (let i in inChoices){
outChoices.push(inChoices[i]);
}
let newChoice = check.createChoice(e.values[3]);
outChoices.push(newChoice);
check.setChoices(outChoices);
}