Skip to content

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

Change these values

Make the code yours before you run it.
Title question
Event title

Exact title of the Short answer question.

Start question
Start date and time

Exact title of the Date + time question.

Duration minutes
60

Length 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.

Code.gs
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

  1. 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.

  2. 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.

  3. 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.

  4. 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