Task guide
Create Calendar events from Form submissions
Schedule a Google Calendar event whenever someone submits a Google Form, using the title, date, and duration from the submission.
1 · Prepare
Put these pieces in place
- Open the script editor bound to your Google Form (three-dot menu at the top right, then Script editor).
- Include a Short answer question titled "Event title" and a Date question (with time enabled) titled "Start date and time".
- Sign in as the account whose default Google Calendar should receive the new events.
Change these values
- Title question
Event titleExact title of the Short answer question.
- Start question
Start date and timeExact title of the Date + time question.
- Duration minutes
60Length of each created event in minutes.
2 · Review before running
What the script can access and change
Permissions you approve
- View and manage your forms in Google Drive. The code only reads the submitted answers from event.response.
- See, edit, share, and permanently delete all the calendars you can access using Google Calendar. The code only adds one new event per submission to your default calendar.
Effects of one run
- Creates one event on the trigger owner's default Google Calendar each time the form is submitted.
- Does not modify or delete existing calendar events, and does not send guest invites.
3 · Copy
Paste this into the Apps Script editor
Create or open a script file, replace the example values marked above, then save the project.
const TITLE_QUESTION = 'Event title'; // Exact title of the Short answer question.
const START_QUESTION = 'Start date and time'; // Exact title of the Date + time question.
const DURATION_MINUTES = 60; // Length of each created event in minutes.
/** @param {Events.FormsOnFormSubmit} event */
function createCalendarEventOnFormSubmit(event) {
if (!event || !event.response) {
Logger.log('Submit the form to test this trigger rather than clicking Run.');
return;
}
const answers = new Map();
event.response.getItemResponses().forEach((itemResponse) => {
answers.set(itemResponse.getItem().getTitle(), String(itemResponse.getResponse()).trim());
});
const title = answers.get(TITLE_QUESTION);
const startRaw = answers.get(START_QUESTION);
if (!title || !startRaw) {
throw new Error('Missing required answers for "' + TITLE_QUESTION + '" or "' + START_QUESTION + '".');
}
const startTime = new Date(startRaw);
if (Number.isNaN(startTime.getTime())) {
throw new Error('Could not parse "' + startRaw + '" as a date and time.');
}
const endTime = new Date(startTime.getTime() + DURATION_MINUTES * 60 * 1000);
const calendar = CalendarApp.getDefaultCalendar();
const created = calendar.createEvent(title, startTime, endTime, {
description: 'Booked via Google Form response ' + event.response.getId(),
});
Logger.log('Created event ' + created.getId() + ' starting ' + startTime.toISOString());
} 4 · Run
Follow these steps in order
Add the two questions to the Form
Add a required Short answer question titled Event title and a required Date question titled Start date and time, with Include time enabled in its three-dot menu.
Paste the function and save
Open the Form script editor, replace the starter code with this function, and save. Do not click Run directly because there is no submitted response yet.
Install the On form submit trigger
Open Triggers in the left sidebar, click Add Trigger, choose createCalendarEventOnFormSubmit, select From form and On form submit, then click Save and approve Forms and Calendar access.
Submit one test response
Preview the form, enter a test title and a date and time later today, and submit. Open Google Calendar and verify the new event appears at that time.
5 · Confirm
How to tell it worked
Within a minute of submitting the form, a matching event of DURATION_MINUTES length appears on your default Google Calendar with the response ID in its description.
If the result is different
Troubleshooting
- Clicking Run in the editor logs that there is no event, or throws undefined reading response.
- Form submit handlers only receive event.response when a form submission fires the trigger. Test by submitting the live form.
- Executions reports "Could not parse ... as a date and time."
- Open the Date question in the Form editor, click its three-dot menu, and make sure Include time is turned on so the answer includes both date and clock time.
Technical details
Names used in this script
Open these details when you want to adapt the example or look up an exact service or method name.
Show Apps Script symbols and service pages
Keep going
Related tasks, basics, and apps
- Task guide Respond to a Google Form submission
Get an email every time someone submits your Google Form, listing each question and its answer. The email goes only to you, the owner of the script.
- Task guide Create Calendar events from Sheet rows
Turn rows on an Events tab into events on your Google Calendar. The script creates an event for each row that has no event ID yet, then writes the new ID back into the row so a later run skips it.
- Task guide Export Calendar events to a Google Sheet
Read events from your Google Calendar for a chosen number of upcoming days and write their titles, times, locations, and guest counts to a Google Sheet tab.
- Object reference Form response
A FormResponse contains the answers sent in one Google Form submission. A form-bound submit trigger passes it to your function as event.response, where getItemResponses() returns the submitted item responses.
- Object reference Item response
An ItemResponse pairs one Google Form question with the answer submitted for it. Reach item responses from formResponse.getItemResponses(), then call getItem().getTitle() and getResponse().
- Object reference Calendar
A calendar holds a set of events. Most scripts use your default calendar, but you can also open another calendar you have access to by its ID.
- Object reference Calendar event
A calendar event is one entry on a calendar, such as a meeting or a reminder. It carries a title, a start and end time, and an optional guest list.
- Object reference Trigger builder
ScriptApp.newTrigger(functionName) returns a TriggerBuilder that configures a timeBased(), forSpreadsheet(), or forForm() trigger before create() saves it.
- Google app Google Forms
FormApp scripts and form-submit triggers read new Google Form responses via event.response, populate dropdown questions from Google Sheets, and trigger email or Calendar actions.
- Google app Triggers
A trigger is a saved schedule or event rule in ScriptApp that runs your function on time, on edit, or on form submit.
- Google app Google Calendar
CalendarApp scripts read events with getEvents() or getEventsForDay(), export schedules to Google Sheets, and create CalendarEvent entries from Sheet rows or Form submissions.
- Diagnostic Cannot read properties of undefined (reading 'range')
Why trigger functions receive undefined when started from the editor Run button and how to test them.