Make a real Google Form with code
Apps Script recipes › Email, Docs, Forms and PDF
Creates a Google Form once, keeps its ID, sends its responses to the project's Sheet and returns its links.
File Code.gs
function setupForm() {
const props = PropertiesService.getScriptProperties();
const id = props.getProperty('FORM_ID');
if (id) {
const form = FormApp.openById(id);
return { url: form.getPublishedUrl(), editUrl: form.getEditUrl() };
}
const form = FormApp.create('Registration');
form.setCollectEmail(true);
form.addTextItem().setTitle('Full name').setRequired(true);
form.addMultipleChoiceItem().setTitle('Session').setChoiceValues(['Morning', 'Afternoon']).setRequired(true);
form.addParagraphTextItem().setTitle('Notes');
form.setDestination(FormApp.DestinationType.SPREADSHEET, SHEET_ID);
props.setProperty('FORM_ID', form.getId());
return { url: form.getPublishedUrl(), editUrl: form.getEditUrl() };
}
Good to know
- Run it once (the AI can run it for you); later runs reuse the same Form instead of making a new one.
Let the AI put it in your appGAS AI Builder knows every recipe here. Describe your app and it uses this code where it fits, in a Google Apps Script project in your own Drive.
Use it in a project