Skip to main content

Added calendar

Google Apps Script has a standard CalendarApp class, which is a library for operating Google Calendar.

Here, we will explain how to create a new calendar and add it to the account using the CalendarApp class.

Since GAS will access Google Calendar, you will need to set the authority at the first run.

Function to use

Use the following functions to add the event.

Function details
CalendarApp.createCalendar([Calendar name], [Options (optional)]);

Use the createCalendar method prepared in CalendarApp`.

By specifying the calendar name for the argument, a new calendar is created.

You can receive the calendar object created as a return value, so you can start operation immediately after creation.

Sample code

Create a new calendar
function myFunction() {
const calendar = CalendarApp.createCalendar('New calendar');

console.log(
`A calendar named "${calendar.getName()}" has been created.The ID is ${calendar.getId()}.`
);
}

By execution, a new calendar will be added to your Google Calendar.