Class CalendarEvent

CalendarEvent

Representa um único evento da agenda.

Métodos

MétodoTipo de retornoBreve descrição
addEmailReminder(minutesBefore)CalendarEventAdiciona um novo lembrete por e-mail ao evento.
addGuest(email)CalendarEventAdiciona um convidado ao evento.
addPopupReminder(minutesBefore)CalendarEventAdiciona uma nova notificação pop-up ao evento.
addSmsReminder(minutesBefore)CalendarEventAdiciona um novo lembrete por SMS ao evento.
anyoneCanAddSelf()BooleanDetermina se as pessoas podem se adicionar como convidados a um evento do Google Agenda.
deleteEvent()voidExclui um evento da Agenda.
deleteTag(key)CalendarEventExclui uma tag de chave/valor do evento.
getAllDayEndDate()DateRecebe a data de término deste evento de dia inteiro da agenda.
getAllDayStartDate()DateRecebe a data de início do evento de dia inteiro da agenda.
getAllTagKeys()String[]Recebe todas as chaves das tags definidas no evento.
getColor()StringRetorna a cor do evento da agenda.
getCreators()String[]Recebe os criadores de um evento.
getDateCreated()DateRecebe a data em que o evento foi criado.
getDescription()StringRecebe a descrição do evento.
getEmailReminders()Integer[]Recebe os valores de minuto de todos os lembretes por e-mail do evento.
getEndTime()DateRecebe a data e a hora em que o evento da agenda termina.
getEventSeries()CalendarEventSeriesRecebe a série de eventos recorrentes a que este evento pertence.
getEventType()EventTypeRecebe o EventType deste evento.
getGuestByEmail(email)EventGuestRecebe um convidado pelo endereço de e-mail.
getGuestList()EventGuest[]Recebe os convidados do evento, sem incluir o proprietário.
getGuestList(includeOwner)EventGuest[]Recebe os convidados do evento, incluindo possivelmente os proprietários.
getId()StringRecebe o iCalUID exclusivo do evento.
getLastUpdated()DateRecebe a data da última atualização do evento.
getLocation()StringRecebe o local do evento.
getMyStatus()GuestStatusRecebe o status do evento (como participação ou convite) do usuário efetivo.
getOriginalCalendarId()StringReceba o ID da agenda em que o evento foi criado originalmente.
getPopupReminders()Integer[]Recebe os valores de minuto de todos os lembretes pop-up do evento.
getSmsReminders()Integer[]Recebe os valores de minuto de todos os lembretes por SMS do evento.
getStartTime()DateRecebe a data e a hora em que o evento da agenda começa.
getTag(key)StringRecebe um valor de tag do evento.
getTitle()StringRecebe o título do evento.
getTransparency()EventTransparencyRecebe a transparência do evento.
getVisibility()VisibilityRecebe a visibilidade do evento.
guestsCanInviteOthers()BooleanDetermina se os convidados podem convidar outras pessoas.
guestsCanModify()BooleanDetermina se os convidados podem modificar o evento.
guestsCanSeeGuests()BooleanDetermina se os convidados podem ver outros convidados.
isAllDayEvent()BooleanDetermina se é um evento de dia inteiro.
isOwnedByMe()BooleanDetermina se você é o proprietário do evento.
isRecurringEvent()BooleanDetermina se o evento faz parte de uma série de eventos.
removeAllReminders()CalendarEventRemove todos os lembretes do evento.
removeGuest(email)CalendarEventRemove um convidado do evento.
resetRemindersToDefault()CalendarEventRedefine os lembretes usando as configurações padrão da agenda.
setAllDayDate(date)CalendarEventDefine a data do evento.
setAllDayDates(startDate, endDate)CalendarEventDefine as datas do evento.
setAnyoneCanAddSelf(anyoneCanAddSelf)CalendarEventDefine se pessoas que não são convidadas podem se adicionar ao evento.
setColor(color)CalendarEventDefine a cor do evento da agenda.
setDescription(description)CalendarEventDefine a descrição do evento.
setGuestsCanInviteOthers(guestsCanInviteOthers)CalendarEventDefine se os convidados podem convidar outras pessoas.
setGuestsCanModify(guestsCanModify)CalendarEventDefine se os convidados podem modificar o evento.
setGuestsCanSeeGuests(guestsCanSeeGuests)CalendarEventDefine se os convidados podem ver outros convidados.
setLocation(location)CalendarEventDefine o local do evento.
setMyStatus(status)CalendarEventDefine o status do evento (como participação ou convite) do usuário efetivo.
setTag(key, value)CalendarEventDefine uma tag de chave/valor no evento para armazenar metadados personalizados.
setTime(startTime, endTime)CalendarEventDefine as datas e os horários de início e término do evento.
setTitle(title)CalendarEventDefine o título do evento.
setTransparency(transparency)CalendarEventDefine a transparência do evento.
setVisibility(visibility)CalendarEventDefine a visibilidade do evento.

Documentação detalhada

addEmailReminder(minutesBefore)

Adiciona um novo lembrete por e-mail ao evento. O lembrete precisa ser de pelo menos 5 minutos e, no máximo, 4 semanas (40.320 minutos) antes do evento.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId)
// instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Adds an email notification for 15 minutes before the event.
event.addEmailReminder(15);

Parâmetros

NomeTipoDescrição
minutesBeforeIntegero número de minutos antes do evento

Retornar

CalendarEvent: CalendarEvent para encadeamento

Gera

Error: se houver mais de cinco lembretes no evento ou se o horário não estiver dentro do intervalo permitido.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

addGuest(email)

Adiciona um convidado ao evento.

// Example 1: Add a guest to one event
function addAttendeeToEvent() {
  // Replace the below values with your own
  const attendeeEmail =
      'user@example.com';  // Email address of the person you need to add
  const calendarId =
      'calendar_123@group.calendar.google.com';  // ID of calendar containing
  // event
  const eventId = '123abc';  // ID of event instance

  const calendar = CalendarApp.getCalendarById(calendarId);
  if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
  }
  const event = calendar.getEventById(eventId);
  if (event === null) {
    // Event not found
    console.log('Event not found', eventId);
    return;
  }
  event.addGuest(attendeeEmail);
}

// Example 2: Add a guest to all events on a calendar within a specified
// timeframe
function addAttendeeToAllEvents() {
  // Replace the following values with your own
  const attendeeEmail =
      'user@example.com';  // Email address of the person you need to add
  const calendarId =
      'calendar_123@group.calendar.google.com';  // ID of calendar with the
  // events
  const startDate =
      new Date('YYYY-MM-DD');  // The first date to add the guest to the events
  const endDate =
      new Date('YYYY-MM-DD');  // The last date to add the guest to the events

  const calendar = CalendarApp.getCalendarById(calendarId);
  if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
  }
  // Get the events within the specified timeframe
  const calEvents = calendar.getEvents(startDate, endDate);
  console.log(calEvents.length);  // Checks how many events are found
  // Loop through all events and add the attendee to each of them
  for (let i = 0; i < calEvents.length; i++) {
    const event = calEvents[i];
    event.addGuest(attendeeEmail);
  }
}

Parâmetros

NomeTipoDescrição
emailStringO endereço de e-mail do convidado.

Retornar

CalendarEvent: CalendarEvent para encadeamento.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

addPopupReminder(minutesBefore)

Adiciona uma nova notificação pop-up ao evento. A notificação precisa ser enviada entre 5 minutos e 4 semanas (40.320 minutos) antes do evento.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId)
// instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Adds a pop-up notification for 15 minutes before the event.
event.addPopupReminder(15);

Parâmetros

NomeTipoDescrição
minutesBeforeIntegero número de minutos antes do evento

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

addSmsReminder(minutesBefore)

Adiciona um novo lembrete por SMS ao evento. O lembrete precisa ser de pelo menos 5 minutos e, no máximo, 4 semanas (40.320 minutos) antes do evento.

Parâmetros

NomeTipoDescrição
minutesBeforeIntegero número de minutos antes do evento

Retornar

CalendarEvent: CalendarEvent para encadeamento

Gera

Error: se houver mais de cinco lembretes no evento ou se o horário não estiver dentro do intervalo permitido.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

anyoneCanAddSelf()

Determina se as pessoas podem se adicionar como convidados a um evento do Google Agenda.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId)
// instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Determines whether people can add themselves as guests to the event and logs
// it.
console.log(event.anyoneCanAddSelf());

Retornar

Booleantrue se pessoas que não são convidadas puderem se adicionar ao evento; false se não puderem

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

deleteEvent()

Exclui um evento da Agenda.

// Gets an event by its ID.
// TODO(developer): Replace the string with the ID of the event that you want to
// delete.
const event = CalendarApp.getEventById('abc123456');

// Deletes the event.
event.deleteEvent();

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

deleteTag(key)

Exclui uma tag de chave/valor do evento.

Parâmetros

NomeTipoDescrição
keyStringa chave de tag

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

getAllDayEndDate()

Recebe a data de término deste evento de dia inteiro da agenda. Se não for um evento de dia inteiro, esse método vai gerar uma exceção. O Date retornado representa a meia-noite do início do dia após o término do evento no fuso horário do script. Para usar o fuso horário do calendário, chame getEndTime().

// Gets the user's default calendar. To get a different calendar,
// use getCalendarById() instead.
const calendar = CalendarApp.getDefaultCalendar();

// Creates an event named 'My all-day event' for May 16, 2023.
const event = calendar.createAllDayEvent(
    'My all-day event',
    new Date('May 16, 2023'),
);

// Gets the event's end date and logs it.
const endDate = event.getAllDayEndDate();
console.log(endDate);

Retornar

Date: a data de término deste evento da agenda que dura o dia todo

Gera

Error — se o evento não for de dia inteiro

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getAllDayStartDate()

Recebe a data de início do evento de dia inteiro da agenda. Se não for um evento de dia inteiro, esse método vai gerar uma exceção. O Date retornado representa a meia-noite no início do dia em que o evento começa no fuso horário do script. Para usar o fuso horário do calendário, chame getStartTime().

// Gets the user's default calendar. To get a different calendar,
// use getCalendarById() instead.
const calendar = CalendarApp.getDefaultCalendar();

// Creates an event named 'My all-day event' for May 16, 2023.
const event = calendar.createAllDayEvent(
    'My all-day event',
    new Date('May 16, 2023'),
);

// Gets the event's start date and logs it.
const startDate = event.getAllDayStartDate();
console.log(startDate);

Retornar

Date: data de início deste evento da agenda que dura o dia todo

Gera

Error — se o evento não for de dia inteiro

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getAllTagKeys()

Recebe todas as chaves das tags definidas no evento.

Retornar

String[]: uma matriz de chaves de string

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getColor()

Retorna a cor do evento da agenda.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId)
// instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Gets the color of the calendar event and logs it.
const eventColor = event.getColor();
console.log(eventColor);

Retornar

String: a representação de string da cor do evento, como um índice (1 a 11) de valores de CalendarApp.EventColor.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getCreators()

Recebe os criadores de um evento.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId)
// instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Gets a list of the creators of the event and logs it.
console.log(event.getCreators());

Retornar

String[]: os endereços de e-mail dos criadores do evento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getDateCreated()

Recebe a data em que o evento foi criado. Você precisa ter acesso à agenda.

// Opens the calendar by using its ID.
// To get the user's default calendar use CalendarApp.getDefault() instead.
// TODO(developer): Replace the calendar ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 8:10 AM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 08:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, gets the date that the
  // event was created and logs it.
  const eventCreated = event.getDateCreated();
  console.log(eventCreated);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Date: a data de criação

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getDescription()

Recebe a descrição do evento. Você precisa ter acesso de edição na agenda.

// Opens the calendar by its ID.
// To get the user's default calendar use CalendarApp.getDefault() instead.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 4th, 2023 that takes
// place between 4:00 PM and 5:00 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 04, 2023 16:00:00'),
    new Date('Feb 04, 2023 17:00:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the description of the
  // event.
  event.setDescription('Important meeting');

  // Gets the description of the event and logs it.
  const description = event.getDescription();
  console.log(description);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

String: a descrição

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEmailReminders()

Recebe os valores de minuto de todos os lembretes por e-mail do evento. Você precisa ter acesso de edição ao calendário.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 4th, 2023 that takes
// place between 5:00 PM and 6:00 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 04, 2023 15:00:00'),
    new Date('Feb 04, 2023 18:00:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, adds email reminders for
  // the user to be sent at 4 and 7 minutes before the event.
  event.addEmailReminder(4);
  event.addEmailReminder(7);

  // Gets the minute values for all email reminders that are set up for the user
  // for this event and logs it.
  const emailReminder = event.getEmailReminders();
  console.log(emailReminder);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Integer[]: uma matriz em que cada valor corresponde ao número de minutos antes do evento em que um lembrete é acionado.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEndTime()

Recebe a data e a hora em que o evento da agenda termina. Você precisa ter acesso à agenda. Para eventos que não são de dia inteiro, este é o instante em que o evento foi definido para terminar. Para eventos de dia inteiro, que armazenam apenas uma data de término (não uma data e hora), esse é o horário da meia-noite no início do dia após o término do evento no fuso horário da agenda. Isso permite uma comparação significativa dos horários de término para todos os tipos de eventos, mas não preserva necessariamente o dia do ano original sem modificações.

Para eventos de dia inteiro, getAllDayEndDate() quase sempre deve ser chamado em vez desse método.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:00 PM and 5:00 PM.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:00:00'),
    new Date('Feb 01, 2023 17:00:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, gets the date and time at
  // which the event ends and logs it.
  console.log(event.getEndTime());
} else {
  // If no event exists within the given time frame, logs that info to the
  // console.
  console.log('No events exist for the specified range');
}

Retornar

Date: horário de término do evento da agenda

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEventSeries()

Recebe a série de eventos recorrentes a que este evento pertence. Você precisa ter acesso ao calendário. Um objeto CalendarEventSeries é retornado mesmo que o evento não pertença a uma série, para que você possa adicionar novas configurações de recorrência.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 18th, 2023 that takes
// place between 1:00 PM and 2:00 PM.
const event = calendar.getEvents(
    new Date('Feb 18, 2023 13:00:00'),
    new Date('Feb 18, 2023 14:00:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, gets the event series for
  // the event and sets the color to pale green.
  event.getEventSeries().setColor(CalendarApp.EventColor.PALE_GREEN);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

CalendarEventSeries: a série de eventos a que este evento pertence ou uma nova série de eventos se ele ainda não pertencer a uma série.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEventType()

Recebe o EventType deste evento.

// Opens the default calendar and logs all out-of-office events for the current day.
const calendar = CalendarApp.getDefaultCalendar();
const events = calendar.getEventsForDay(new Date());
console.log(events.filter(e => e.getEventType() === CalendarApp.EventType.OUT_OF_OFFICE));

Retornar

EventType: o tipo de evento.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getGuestByEmail(email)

Recebe um convidado pelo endereço de e-mail.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 25th, 2023 that takes
// place between 5:00 PM and 5:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 25,2023 17:00:00'),
    new Date('Feb 25,2023 17:25:00'),
    )[0];

// Gets a guest by email address.
const guestEmailId = event.getGuestByEmail('alex@example.com');

// If the email address corresponds to an event guest, logs the email address.
if (guestEmailId) {
  console.log(guestEmailId.getEmail());
}

Parâmetros

NomeTipoDescrição
emailStringo endereço do hóspede

Retornar

EventGuest: o convidado ou nulo se o endereço de e-mail não corresponder a um convidado.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

getGuestList()

Recebe os convidados do evento, sem incluir o proprietário.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 25th, 2023 that takes
// place between 5:00 PM and 5:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 25,2023 17:00:00'),
    new Date('Feb 25,2023 17:25:00'),
    )[0];

// Adds two guests to the event by using their email addresses.
event.addGuest('alex@example.com');
event.addGuest('cruz@example.com');

// Gets the guests list for the event.
const guestList = event.getGuestList();

// Loops through the list to get all the guests and logs their email addresses.
for (const guest of guestList) {
  console.log(guest.getEmail());
}

Retornar

EventGuest[]: uma matriz dos convidados

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getGuestList(includeOwner)

Recebe os convidados do evento, incluindo possivelmente os proprietários.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 25th, 2023 that takes
// place between 5:00 PM and 5:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 25,2023 17:00:00'),
    new Date('Feb 25,2023 17:25:00'),
    )[0];

// Gets the guests list for the event, including the owner of the event.
const guestList = event.getGuestList(true);

// Loops through the list to get all the guests and logs it.
for (const guest of guestList) {
  console.log(guest.getEmail());
}

Parâmetros

NomeTipoDescrição
includeOwnerBooleanse os proprietários devem ser incluídos como convidados

Retornar

EventGuest[]: uma matriz dos convidados

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getId()

Recebe o iCalUID exclusivo do evento. O iCalUID e o id do evento usado pela API Calendar v3 e pelo serviço avançado do Google Agenda não são idênticos e não podem ser usados de forma intercambiável. Uma diferença na semântica é que, em eventos recorrentes, todas as ocorrências de um evento têm ids diferentes, mas compartilham os mesmos iCalUIDs.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for January 5th, 2023 that takes place
// between 9:00 AM and 9:25 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event = calendar.getEvents(
    new Date('Jan 05, 2023 09:00:00'),
    new Date('Jan 05, 2023 09:25:00'),
    )[0];

// Gets the ID of the event and logs it.
console.log(event.getId());

Retornar

String: o iCalUID do evento.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getLastUpdated()

Recebe a data da última atualização do evento.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:00 PM and 5:00 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:00:00'),
    new Date('Feb 01, 2023 17:00:00'),
    )[0];

// Gets the date the event was last updated and logs it.
const eventUpdatedDate = event.getLastUpdated();
console.log(eventUpdatedDate);

Retornar

Date: a data da última atualização

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getLocation()

Recebe o local do evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the location of the
  // event to Mumbai.
  event.setLocation('Mumbai');

  // Gets the location of the event and logs it.
  const eventLocation = event.getLocation();
  console.log(eventLocation);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

String: o local do evento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getMyStatus()

Recebe o status do evento (como participação ou convite) do usuário efetivo. Sempre retorna GuestStatus.OWNER se o usuário efetivo for o proprietário do evento.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, gets the event status of
  // the effective user and logs it.
  const myStatus = event.getMyStatus();
  console.log(myStatus.toString());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

GuestStatus: o status

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getOriginalCalendarId()

Receba o ID da agenda em que o evento foi criado originalmente.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 25th, 2023 that takes
// place between 4:00 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 25,2023 16:00:00'),
    new Date('Feb 25,2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, gets the ID of the calendar
  // where the event was originally created and logs it.
  const calendarId = event.getOriginalCalendarId();
  console.log(calendarId);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

String: o ID da agenda original

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getPopupReminders()

Recebe os valores de minuto de todos os lembretes pop-up do evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 4th, 2023 that takes
// place between 5:05 PM and 5:35 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 04, 2023 17:05:00'),
    new Date('Feb 04, 2023 17:35:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, adds two pop-up reminders
  // to the event. The first reminder pops up 5 minutes before the event starts
  // and the second reminder pops up 3 minutes before the event starts.
  event.addPopupReminder(3);
  event.addPopupReminder(5);

  // Gets the minute values for all pop-up reminders for the event and logs it.
  const popUpReminder = event.getPopupReminders();
  console.log(popUpReminder);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Integer[]: uma matriz em que cada valor corresponde ao número de minutos antes do evento em que um lembrete é acionado.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getSmsReminders()

Recebe os valores de minuto de todos os lembretes por SMS do evento.

Retornar

Integer[]: uma matriz em que cada valor corresponde ao número de minutos antes do evento em que um lembrete é acionado.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getStartTime()

Recebe a data e a hora em que o evento da agenda começa. Para eventos que não são de dia inteiro, esse é o instante em que o evento foi definido para começar. Para eventos de dia inteiro, que armazenam apenas uma data de início (não uma data e hora), esse é o horário da meia-noite no início do dia em que o evento começa no fuso horário da agenda. Isso permite uma comparação significativa dos horários de início de todos os tipos de eventos, mas não necessariamente preserva o dia do ano original sem modificações.

Para eventos de dia inteiro, getAllDayStartDate() quase sempre deve ser chamado em vez desse método.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

// Gets the date and time at which this calendar event begins and logs it.
const startTime = event.getStartTime();
console.log(startTime);

Retornar

Date: horário de início do evento da agenda

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getTag(key)

Recebe um valor de tag do evento.

Parâmetros

NomeTipoDescrição
keyStringa chave

Retornar

String: o valor da tag.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getTitle()

Recebe o título do evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for January 31st, 2023 that takes
// place between 9:05 AM and 9:15 AM. For an event series, use
// calendar.getEventSeriesById('abc123456@example.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Jan 31, 2023 09:05:00'),
    new Date('Jan 31, 2023 09:15:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, logs the title of the
  // event.
  console.log(event.getTitle());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

String: o título

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getTransparency()

Recebe a transparência do evento. Use esse método para determinar se um evento é TRANSPARENT, ou seja, a agenda aparece como "Disponível" durante esse período, ou OPAQUE , ou seja, a agenda aparece como "Ocupado" durante esse período.

// Gets the first event from the default calendar for today.
const today = new Date();
const event = CalendarApp.getDefaultCalendar().getEventsForDay(today)[0];
// Gets the event's transparency and logs it.
const transparency = event.getTransparency();
Logger.log(transparency);

Retornar

EventTransparency: o valor de transparência.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getVisibility()

Recebe a visibilidade do evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, gets the visibility of the
  // event and logs it.
  const eventVisibility = event.getVisibility();
  console.log(eventVisibility.toString());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Visibility: o valor de visibilidade.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

guestsCanInviteOthers()

Determina se os convidados podem convidar outras pessoas.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 9:35 AM and 9:40 AM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 09:35:00'),
    new Date('Feb 01, 2023 09:40:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, determines whether guests
  // can invite other guests and logs it.
  console.log(event.guestsCanInviteOthers());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Booleantrue se os convidados puderem convidar outras pessoas; false se não puderem

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

guestsCanModify()

Determina se os convidados podem modificar o evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 9:35 AM and 9:40 AM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 09:35:00'),
    new Date('Feb 01, 2023 09:40:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the event so that
  // guests can't modify it.
  event.setGuestsCanModify(false);

  // Determines whether guests can modify the event and logs it.
  console.log(event.guestsCanModify());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Booleantrue se os convidados puderem modificar o evento; false se não puderem

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

guestsCanSeeGuests()

Determina se os convidados podem ver outros convidados.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 9:35 AM and 9:40 AM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 09:35:00'),
    new Date('Feb 01, 2023 09:40:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, determines whether guests
  // can see other guests and logs it.
  console.log(event.guestsCanSeeGuests());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Boolean: true se os convidados puderem ver outros convidados; false se não puderem

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isAllDayEvent()

Determina se é um evento de dia inteiro.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for January 31st, 2023 that takes
// place between 9:05 AM and 9:15 AM.
const event = calendar.getEvents(
    new Date('Jan 31, 2023 09:05:00'),
    new Date('Jan 31, 2023 09:15:00'),
    )[0];

// Determines whether this event is an all-day event and logs it.
console.log(event.isAllDayEvent());

Retornar

Boolean: true se o evento for de dia inteiro; false se não for

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isOwnedByMe()

Determina se você é o proprietário do evento.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for January 31st, 2023 that takes
// place between 9:05 AM and 9:15 AM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Jan 31, 2023 09:05:00'),
    new Date('Jan 31, 2023 09:15:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, determines whether you're
  // the owner of the event and logs it.
  console.log(event.isOwnedByMe());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Boolean: true se o evento for de propriedade do usuário efetivo; false se não for.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isRecurringEvent()

Determina se o evento faz parte de uma série de eventos.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for Januart 31st, 2023 that takes
// place between 9:00 AM and 10:00 AM.
const event = calendar.getEvents(
    new Date('Jan 31, 2023 09:00:00'),
    new Date('Jan 31, 2023 10:00:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, determines whether the
  // event is part of an event series and logs it.
  console.log(event.isRecurringEvent());
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

Boolean: true se o evento fizer parte de uma série de eventos; false se não fizer.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

removeAllReminders()

Remove todos os lembretes do evento.

// Opens the calendar by its ID. You must have edit access to the calendar
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 1,2023 16:10:00'),
    new Date('Feb 1,2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, removes all reminders from
  // the event.
  event.removeAllReminders();
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

removeGuest(email)

Remove um convidado do evento.

// Example 1: Remove a guest from one event
function removeGuestFromEvent() {
  // Replace the below values with your own
  const attendeeEmail =
      'user@example.com';  // Email address of the person you need to remove
  const calendarId =
      'calendar_123@group.calendar.google.com';  // ID of calendar containing
  // event
  const eventId = '123abc';  // ID of event instance

  const calendar = CalendarApp.getCalendarById(calendarId);
  if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
  }
  const event = calendar.getEventById(eventId);
  if (event === null) {
    // Event not found
    console.log('Event not found', eventId);
    return;
  }
  event.removeGuest(attendeeEmail);
}

// Example 2: Remove a guest from all events on a calendar within a specified
// timeframe
function removeGuestFromAllEvents() {
  // Replace the following values with your own
  const attendeeEmail =
      'user@example.com';  // Email address of the person you need to remove
  const calendarId =
      'calendar_123@group.calendar.google.com';  // ID of calendar with the
  // events
  const startDate = new Date(
      'YYYY-MM-DD');  // The first date to remove the guest from the events
  const endDate = new Date(
      'YYYY-MM-DD');  // The last date to remove the attendee from the events

  const calendar = CalendarApp.getCalendarById(calendarId);
  if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
  }
  // Get the events within the specified timeframe
  const calEvents = calendar.getEvents(startDate, endDate);
  console.log(calEvents.length);  // Checks how many events are found
  // Loop through all events and remove the attendee from each of them
  for (let i = 0; i < calEvents.length; i++) {
    const event = calEvents[i];
    event.removeGuest(attendeeEmail);
  }
}

Parâmetros

NomeTipoDescrição
emailStringo endereço de e-mail do convidado

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

resetRemindersToDefault()

Redefine os lembretes usando as configurações padrão da agenda.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 1, 2023 16:10:00'),
    new Date('Feb 1, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, resets the reminders using
  // the calendar's default settings.
  event.resetRemindersToDefault();
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setAllDayDate(date)

Define a data do evento. Ao aplicar esse método, um evento regular se torna um evento de dia inteiro.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 17th, 2023 that takes
// place between 4:00 PM and 5:00 PM.
const event = calendar.getEvents(
    new Date('Feb 17, 2023 16:00:00'),
    new Date('Feb 17, 2023 17:00:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the date of the event
  // and updates it to an all-day event.
  event.setAllDayDate(new Date('Feb 17, 2023'));
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
dateDatea data do evento (a hora é ignorada)

Retornar

CalendarEvent: este CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setAllDayDates(startDate, endDate)

Define as datas do evento. Ao aplicar esse método, um evento normal se torna um evento de dia inteiro.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 18th, 2023 that takes
// place between 4:00 PM and 5:00 PM.
const event = calendar.getEvents(
    new Date('Feb 18, 2023 16:00:00'),
    new Date('Feb 18, 2023 17:00:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the event to be an
  // all-day event from Feb 18th, 2023 until Feb 25th, 2023. Applying this
  // method changes a regular event into an all-day event.
  event.setAllDayDates(new Date('Feb 18, 2023'), new Date('Feb 25, 2023'));
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
startDateDatea data de início do evento (a hora é ignorada)
endDateDatea data de término do evento (a hora é ignorada)

Retornar

CalendarEvent: este CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setAnyoneCanAddSelf(anyoneCanAddSelf)

Define se pessoas que não são convidadas podem se adicionar ao evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 15th, 2023 that takes
// place between 3:30 PM and 4:30 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 15, 2023 15:30:00'),
    new Date('Feb 15, 2023 16:30:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the event so that
  // non-guests can't add themselves to the event.
  event.setAnyoneCanAddSelf(false);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
anyoneCanAddSelfBooleanse qualquer pessoa pode se convidar;

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setColor(color)

Define a cor do evento da agenda.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the color of the
  // calendar event to green.
  event.setColor(CalendarApp.EventColor.GREEN);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
colorStringUm índice de cor inteiro como uma string ou um valor de CalendarApp.EventColor.

Retornar

CalendarEvent: este evento da agenda, para encadeamento.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setDescription(description)

Define a descrição do evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 4th, 2023 that takes
// place between 5:05 PM and 5:35 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 04, 2023 17:05:00'),
    new Date('Feb 04, 2023 17:35:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the description of the
  // event to 'Meeting.'
  event.setDescription('Meeting');
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
descriptionStringa nova descrição

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setGuestsCanInviteOthers(guestsCanInviteOthers)

Define se os convidados podem convidar outras pessoas.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own. You must have edit access to
// the calendar.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 9:35 AM and 9:40 AM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 09:35:00'),
    new Date('Feb 01, 2023 09:40:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the event so that
  // guests can invite other guests.
  event.setGuestsCanInviteOthers(true);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
guestsCanInviteOthersBooleanse os convidados podem convidar outras pessoas

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setGuestsCanModify(guestsCanModify)

Define se os convidados podem modificar o evento.

Parâmetros

NomeTipoDescrição
guestsCanModifyBooleanse os convidados podem modificar o evento

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setGuestsCanSeeGuests(guestsCanSeeGuests)

Define se os convidados podem ver outros convidados.

Parâmetros

NomeTipoDescrição
guestsCanSeeGuestsBooleanse os convidados podem ver outras pessoas

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setLocation(location)

Define o local do evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the location of the
  // event to Noida.
  event.setLocation('Noida');
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
locationStringo novo local

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setMyStatus(status)

Define o status do evento (como participação ou convite) do usuário efetivo.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for February 1st, 2023 that takes
// place between 4:10 PM and 4:25 PM. For an event series, use
// calendar.getEventSeriesById('abc123456@google.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Feb 01, 2023 16:10:00'),
    new Date('Feb 01, 2023 16:25:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, sets the event status for
  // the current user to maybe.
  event.setMyStatus(CalendarApp.GuestStatus.MAYBE);
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
statusGuestStatuso novo status

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

setTag(key, value)

Define uma tag de chave/valor no evento para armazenar metadados personalizados.

Parâmetros

NomeTipoDescrição
keyStringa chave de tag
valueStringo valor da tag

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setTime(startTime, endTime)

Define as datas e os horários de início e término do evento. Aplicar esse método muda um evento de dia inteiro para um evento regular.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Declares a start time of 11:00 AM on February 20th, 2023 and an end time of
// 12:00 PM on February 20th, 2023.
const startTime = new Date('Feb 20,2023 11:00:00');
const endTime = new Date('Feb 20, 2023  12:00:00');

// Creates an all-day event on February 20th, 2023.
const event = calendar.createAllDayEvent('Meeting', new Date('Feb 20,2023'));

// Updates the all-day event to a regular event by setting a start and end time
// for the event.
event.setTime(startTime, endTime);

Parâmetros

NomeTipoDescrição
startTimeDateo novo início do evento
endTimeDateo novo fim do evento

Retornar

CalendarEvent: este CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setTitle(title)

Define o título do evento.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Gets the first event from the calendar for January 31st, 2023 that takes
// place between 9:05 AM and 9:15 AM. For an event series, use
// calendar.getEventSeriesById('abc123456@example.com'); and replace the series
// ID with your own.
const event = calendar.getEvents(
    new Date('Jan 31, 2023 09:05:00'),
    new Date('Jan 31, 2023 09:15:00'),
    )[0];

if (event) {
  // If an event exists within the given time frame, changes its title to
  // Event1.
  event.setTitle('Event1');
} else {
  // If no event exists within the given time frame, logs that information to
  // the console.
  console.log('No events exist for the specified range');
}

Parâmetros

NomeTipoDescrição
titleStringo novo título

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setTransparency(transparency)

Define a transparência do evento. Use esse método para definir se um evento é TRANSPARENT, ou seja, a agenda aparece como "Disponível" durante esse período, ou OPAQUE , ou seja, a agenda aparece como "Ocupado" durante esse período.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId)
// instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');
// Sets the event's transparency to TRANSPARENT.
event.setTransparency(CalendarApp.EventTransparency.TRANSPARENT);

Parâmetros

NomeTipoDescrição
transparencyEventTransparencyO valor de transparência.

Retornar

CalendarEvent: CalendarEvent para encadeamento.

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setVisibility(visibility)

Define a visibilidade do evento.

Parâmetros

NomeTipoDescrição
visibilityVisibility

Retornar

CalendarEvent: CalendarEvent para encadeamento

Autorização

Os scripts que usam esse método exigem autorização com um ou mais dos seguintes escopos ou escopos apropriados da API REST relacionada:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds