Représente un seul événement d'agenda.
Méthodes
Méthode | Type renvoyé | Brève description |
---|---|---|
addEmailReminder(minutesBefore) | CalendarEvent | Ajoute un rappel par e-mail à l'événement. |
addGuest(email) | CalendarEvent | Ajoute un invité à l'événement. |
addPopupReminder(minutesBefore) | CalendarEvent | Ajoute une notification pop-up à l'événement. |
addSmsReminder(minutesBefore) | CalendarEvent | Ajoute un rappel par SMS à l'événement. |
anyoneCanAddSelf() | Boolean | Détermine si les utilisateurs peuvent s'ajouter en tant qu'invités à un événement Agenda. |
deleteEvent() | void | Supprime un événement d'agenda. |
deleteTag(key) | CalendarEvent | Supprime un tag clé-valeur de l'événement. |
getAllDayEndDate() | Date | Récupère la date à laquelle se termine cet événement d'agenda d'une journée entière. |
getAllDayStartDate() | Date | Récupère la date à laquelle commence cet événement d'agenda d'une journée entière. |
getAllTagKeys() | String[] | Récupère toutes les clés des tags définis au niveau de l'événement. |
getColor() | String | Renvoie la couleur de l'événement d'agenda. |
getCreators() | String[] | Récupère les créateurs d'un événement. |
getDateCreated() | Date | Récupère la date de création de l'événement. |
getDescription() | String | Récupère la description de l'événement. |
getEmailReminders() | Integer[] | Récupère les valeurs en minutes de tous les rappels par e-mail pour l'événement. |
getEndTime() | Date | Récupère la date et l'heure auxquelles cet événement d'agenda se termine. |
getEventSeries() | CalendarEventSeries | Récupère la série d'événements périodiques à laquelle cet événement appartient. |
getGuestByEmail(email) | EventGuest | Récupère un invité via son adresse e-mail. |
getGuestList() | EventGuest[] | Récupère les invités à l'événement, à l'exclusion du propriétaire de l'événement. |
getGuestList(includeOwner) | EventGuest[] | Récupère les invités à l'événement, y compris les propriétaires de l'événement. |
getId() | String | Récupère l'UID iCal de l'événement. |
getLastUpdated() | Date | Récupère la date de la dernière mise à jour de l'événement. |
getLocation() | String | Récupère le lieu de l'événement. |
getMyStatus() | GuestStatus | Récupère l'état de l'événement (participant ou invité, par exemple) de l'utilisateur effectif. |
getOriginalCalendarId() | String | Obtenez l'ID de l'agenda dans lequel cet événement a été créé. |
getPopupReminders() | Integer[] | Récupère les valeurs, en minutes, de tous les rappels pop-up concernant l'événement. |
getSmsReminders() | Integer[] | Récupère les valeurs en minutes de tous les rappels par SMS de l'événement. |
getStartTime() | Date | Récupère la date et l'heure à laquelle cet événement d'agenda commence. |
getTag(key) | String | Récupère la valeur de la balise de l'événement. |
getTitle() | String | Récupère le titre de l'événement. |
getVisibility() | Visibility | Récupère la visibilité de l'événement. |
guestsCanInviteOthers() | Boolean | Détermine si les invités peuvent inviter d'autres personnes. |
guestsCanModify() | Boolean | Détermine si les invités peuvent modifier l'événement. |
guestsCanSeeGuests() | Boolean | Détermine si les invités peuvent voir les autres invités. |
isAllDayEvent() | Boolean | Détermine si l'événement dure toute la journée. |
isOwnedByMe() | Boolean | Détermine si vous êtes le propriétaire de l'événement. |
isRecurringEvent() | Boolean | Détermine si l'événement fait partie d'une série d'événements. |
removeAllReminders() | CalendarEvent | Supprime tous les rappels de l'événement. |
removeGuest(email) | CalendarEvent | Supprime un invité de l'événement. |
resetRemindersToDefault() | CalendarEvent | Réinitialise les rappels à l'aide des paramètres par défaut de l'agenda. |
setAllDayDate(date) | CalendarEvent | Définit la date de l'événement. |
setAllDayDates(startDate, endDate) | CalendarEvent | Définit les dates de l'événement. |
setAnyoneCanAddSelf(anyoneCanAddSelf) | CalendarEvent | Détermine si les utilisateurs qui ne sont pas des invités peuvent s'ajouter à l'événement. |
setColor(color) | CalendarEvent | Définit la couleur de l'événement d'agenda. |
setDescription(description) | CalendarEvent | Définit la description de l'événement. |
setGuestsCanInviteOthers(guestsCanInviteOthers) | CalendarEvent | Détermine si les invités peuvent inviter d'autres personnes. |
setGuestsCanModify(guestsCanModify) | CalendarEvent | Détermine si les invités peuvent modifier l'événement. |
setGuestsCanSeeGuests(guestsCanSeeGuests) | CalendarEvent | Détermine si les invités peuvent voir les autres invités. |
setLocation(location) | CalendarEvent | Définit le lieu de l'événement. |
setMyStatus(status) | CalendarEvent | Définit l'état de l'événement (participant ou invité, par exemple) de l'utilisateur effectif. |
setTag(key, value) | CalendarEvent | Définit un tag clé-valeur sur l'événement afin de stocker des métadonnées personnalisées. |
setTime(startTime, endTime) | CalendarEvent | Définit les dates et heures de début et de fin de l'événement. |
setTitle(title) | CalendarEvent | Définit le titre de l'événement. |
setVisibility(visibility) | CalendarEvent | Définit la visibilité de l'événement. |
Documentation détaillée
addEmailReminder(minutesBefore)
Ajoute un rappel par e-mail à l'événement. Le rappel doit être défini entre cinq et quatre semaines (40 320 minutes) avant l'événement.
// 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);
Paramètres
Nom | Type | Description |
---|---|---|
minutesBefore | Integer | le nombre de minutes précédant l'événement ; |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Génère
Error
: si l'événement comprend plus de cinq rappels ou si l'heure n'est pas comprise dans la plage autorisée
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
addGuest(email)
Ajoute un invité à l'événement.
// Example 1: Add a guest to one event function addAttendeeToEvent() { // Replace the below values with your own let attendeeEmail = 'user@example.com'; // Email address of the person you need to add let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar containing event let eventId = '123abc'; // ID of event instance let calendar = CalendarApp.getCalendarById(calendarId); if (calendar === null) { // Calendar not found console.log('Calendar not found', calendarId); return; } let 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 let attendeeEmail = 'user@example.com'; // Email address of the person you need to add let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar with the events let startDate = new Date("YYYY-MM-DD"); // The first date to add the guest to the events let endDate = new Date("YYYY-MM-DD"); // The last date to add the guest to the events let calendar = CalendarApp.getCalendarById(calendarId); if (calendar === null) { // Calendar not found console.log('Calendar not found', calendarId); return; } // Get the events within the specified timeframe let 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 (var i = 0; i < calEvents.length; i++) { let event = calEvents[i]; event.addGuest(attendeeEmail); } }
Paramètres
Nom | Type | Description |
---|---|---|
email | String | Adresse e-mail de l'invité. |
Renvois
CalendarEvent
: CalendarEvent
pour le chaînage.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
addPopupReminder(minutesBefore)
Ajoute une notification pop-up à l'événement. Les notifications doivent être envoyées entre cinq et quatre semaines (40 320 minutes) avant l'événement.
// 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);
Paramètres
Nom | Type | Description |
---|---|---|
minutesBefore | Integer | le nombre de minutes précédant l'événement ; |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
addSmsReminder(minutesBefore)
Ajoute un rappel par SMS à l'événement. Le rappel doit être défini entre cinq et quatre semaines (40 320 minutes) avant l'événement.
Paramètres
Nom | Type | Description |
---|---|---|
minutesBefore | Integer | le nombre de minutes précédant l'événement ; |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Génère
Error
: si l'événement comprend plus de cinq rappels ou si l'heure n'est pas comprise dans la plage autorisée
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
anyoneCanAddSelf()
Détermine si les utilisateurs peuvent s'ajouter en tant qu'invités à un événement 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());
Renvois
Boolean
: true
si des personnes qui ne sont pas des invités peuvent s'ajouter à l'événement ; false
dans le cas contraire.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
deleteEvent()
Supprime un événement d'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();
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
deleteTag(key)
Supprime un tag clé-valeur de l'événement.
Paramètres
Nom | Type | Description |
---|---|---|
key | String | la clé de tag |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
getAllDayEndDate()
Récupère la date à laquelle se termine cet événement d'agenda d'une journée entière. S'il ne s'agit pas d'un événement d'une journée entière, cette méthode génère une exception. Le Date
renvoyé représente minuit au début de la journée suivant la fin de l'événement dans le fuseau horaire du script. Pour utiliser le fuseau horaire du calendrier à la place, appelez 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);
Renvois
Date
: date de fin de cet événement d'agenda d'une journée entière
Génère
Error
: si cet événement ne dure pas toute la journée
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getAllDayStartDate()
Récupère la date à laquelle commence cet événement d'agenda d'une journée entière. S'il ne s'agit pas d'un événement d'une journée entière, cette méthode génère une exception. Le Date
renvoyé représente minuit au début de la journée où l'événement commence dans le fuseau horaire du script. Pour utiliser le fuseau horaire du calendrier à la place, appelez 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);
Renvois
Date
: date de début de cet événement d'agenda d'une journée entière
Génère
Error
: si cet événement ne dure pas toute la journée
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getAllTagKeys()
Récupère toutes les clés des tags définis au niveau de l'événement.
Renvois
String[]
: tableau de clés de chaîne
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getColor()
Renvoie la couleur de l'événement d'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);
Renvois
String
: représentation de la couleur de l'événement sous la forme d'un index (1-11) des valeurs de CalendarApp.EventColor
.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getCreators()
Récupère les créateurs d'un événement.
// 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());
Renvois
String[]
: adresses e-mail des créateurs de l'événement
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getDateCreated()
Récupère la date de création de l'événement. Vous devez avoir accès à l'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'); }
Renvois
Date
: date de création
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getDescription()
Récupère la description de l'événement. Vous devez être autorisé à modifier l'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'); }
Renvois
String
: description
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getEmailReminders()
Récupère les valeurs en minutes de tous les rappels par e-mail pour l'événement. Vous devez être autorisé à modifier l'agenda.
// 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'); }
Renvois
Integer[]
: tableau dans lequel chaque valeur correspond au nombre de minutes précédant l'événement déclenché par un rappel.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getEndTime()
Récupère la date et l'heure auxquelles cet événement d'agenda se termine. Vous devez avoir accès à l'agenda. Pour les événements qui ne durent pas toute la journée, il s'agit de l'heure à laquelle l'événement a été défini pour se terminer. Pour les événements d'une journée, qui ne stockent qu'une date de fin (et non une date et une heure), c'est minuit au début de la journée qui suit la fin de l'événement dans le fuseau horaire de l'agenda. Cela permet de comparer significativement les heures de fin pour tous les types d'événements. Cependant, cela ne conserve pas nécessairement le jour de l'année d'origine tel quel.
Pour les événements d'une journée entière, getAllDayEndDate()
doit presque toujours être appelé de préférence à cette méthode.
// 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'); }
Renvois
Date
: heure de fin de cet événement d'agenda
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getEventSeries()
Récupère la série d'événements périodiques à laquelle cet événement appartient. Vous devez avoir accès à l'agenda. Un objet CalendarEventSeries
est renvoyé même si cet événement n'appartient pas à une série, afin que vous puissiez ajouter de nouveaux paramètres de récurrence.
// 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'); }
Renvois
CalendarEventSeries
: série d'événements à laquelle appartient cet événement ou nouvelle série d'événements si elle n'appartient pas encore à une série
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getGuestByEmail(email)
Récupère un invité via son adresse 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()); }
Paramètres
Nom | Type | Description |
---|---|---|
email | String | l'adresse de l'invité |
Renvois
EventGuest
: l'invité, ou la valeur "null" si l'adresse e-mail ne correspond pas à un invité
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
getGuestList()
Récupère les invités à l'événement, à l'exclusion du propriétaire de l'événement.
// 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()); }
Renvois
EventGuest[]
: tableau des invités
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getGuestList(includeOwner)
Récupère les invités à l'événement, y compris les propriétaires de l'événement.
// 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()); }
Paramètres
Nom | Type | Description |
---|---|---|
includeOwner | Boolean | s'il faut inclure les propriétaires en tant qu'invités |
Renvois
EventGuest[]
: tableau des invités
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getId()
Récupère l'UID iCal de l'événement. Notez que l'identifiant iCalUID et l'événement id
utilisés par l'API Calendar v3 et le service avancé Agenda ne sont pas identiques et ne peuvent pas être utilisés de manière interchangeable. L'une des différences sémantiques réside dans le fait que dans les événements récurrents, toutes les occurrences d'un événement ont un ids
différent alors qu'elles partagent les mêmes UID iCal.
// 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());
Renvois
String
: identifiant iCal de l'événement.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getLastUpdated()
Récupère la date de la dernière mise à jour de l'événement.
// 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);
Renvois
Date
: date de la dernière mise à jour
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getLocation()
Récupère le lieu de l'événement.
// 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'); }
Renvois
String
: lieu de l'événement
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getMyStatus()
Récupère l'état de l'événement (participant ou invité, par exemple) de l'utilisateur effectif. Renvoie toujours GuestStatus.OWNER
si l'utilisateur effectif est le propriétaire de l'événement.
// 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'); }
Renvois
GuestStatus
: état
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getOriginalCalendarId()
Obtenez l'ID de l'agenda dans lequel cet événement a été créé.
// 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'); }
Renvois
String
: ID de l'agenda d'origine.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getPopupReminders()
Récupère les valeurs, en minutes, de tous les rappels pop-up concernant l'événement.
// 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'); }
Renvois
Integer[]
: tableau dans lequel chaque valeur correspond au nombre de minutes précédant l'événement déclenché par un rappel.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getSmsReminders()
Récupère les valeurs en minutes de tous les rappels par SMS de l'événement.
Renvois
Integer[]
: tableau dans lequel chaque valeur correspond au nombre de minutes précédant l'événement déclenché par un rappel.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getStartTime()
Récupère la date et l'heure à laquelle cet événement d'agenda commence. Pour les événements qui ne durent pas toute la journée, il s'agit de l'heure à laquelle l'événement a été défini pour commencer. Pour les événements d'une journée entière, qui ne stockent qu'une date de début (et non une date et une heure), c'est minuit au début de la journée à laquelle commence l'événement dans le fuseau horaire du calendrier. Cela permet de comparer de manière significative les heures de début pour tous les types d'événements. Cependant, cela ne permet pas nécessairement de conserver le jour de l'année d'origine tel quel.
Pour les événements d'une journée entière, getAllDayStartDate()
doit presque toujours être appelé en priorité plutôt que cette méthode.
// 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);
Renvois
Date
: heure de début de cet événement d'agenda
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getTag(key)
Récupère la valeur de la balise de l'événement.
Paramètres
Nom | Type | Description |
---|---|---|
key | String | la clé |
Renvois
String
: valeur de la balise
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getTitle()
Récupère le titre de l'événement.
// 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@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, 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'); }
Renvois
String
: titre
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getVisibility()
Récupère la visibilité de l'événement.
// 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'); }
Renvois
Visibility
: valeur de visibilité
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
guestsCanInviteOthers()
Détermine si les invités peuvent inviter d'autres personnes.
// 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'); }
Renvois
Boolean
: true
si les invités peuvent inviter d'autres personnes ; false
dans le cas contraire.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
guestsCanModify()
Détermine si les invités peuvent modifier l'événement.
// 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'); }
Renvois
Boolean
: true
si les invités peuvent modifier l'événement ; false
dans le cas contraire.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
guestsCanSeeGuests()
Détermine si les invités peuvent voir les autres invités.
// 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'); }
Renvois
Boolean
: true
si les invités peuvent voir les autres invités ; false
dans le cas contraire
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
isAllDayEvent()
Détermine si l'événement dure toute la journée.
// 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());
Renvois
Boolean
: true
si l'événement dure toute la journée ; false
dans le cas contraire
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
isOwnedByMe()
Détermine si vous êtes le propriétaire de l'événement.
// 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'); }
Renvois
Boolean
: true
si l'événement appartient à l'utilisateur effectif ; false
dans le cas contraire.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
isRecurringEvent()
Détermine si l'événement fait partie d'une série d'événements.
// 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'); }
Renvois
Boolean
: true
si l'événement fait partie d'une série d'événements ; false
dans le cas contraire.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
removeAllReminders()
Supprime tous les rappels de l'événement.
// 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'); }
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
removeGuest(email)
Supprime un invité de l'événement.
// Example 1: Remove a guest from one event function removeGuestFromEvent() { // Replace the below values with your own let attendeeEmail = 'user@example.com'; // Email address of the person you need to remove let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar containing event let eventId = '123abc'; // ID of event instance let calendar = CalendarApp.getCalendarById(calendarId); if (calendar === null) { // Calendar not found console.log('Calendar not found', calendarId); return; } let 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 let attendeeEmail = 'user@example.com'; // Email address of the person you need to remove let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar with the events let startDate = new Date("YYYY-MM-DD"); // The first date to remove the guest from the events let endDate = new Date("YYYY-MM-DD"); // The last date to remove the attendee from the events let calendar = CalendarApp.getCalendarById(calendarId); if (calendar === null) { // Calendar not found console.log('Calendar not found', calendarId); return; } // Get the events within the specified timeframe let 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 (var i = 0; i < calEvents.length; i++) { let event = calEvents[i]; event.removeGuest(attendeeEmail); } }
Paramètres
Nom | Type | Description |
---|---|---|
email | String | l'adresse e-mail de l'invité |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
resetRemindersToDefault()
Réinitialise les rappels à l'aide des paramètres par défaut de l'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'); }
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setAllDayDate(date)
Définit la date de l'événement. L'application de cette méthode transforme un événement standard en événement d'une journée entière.
// 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
date | Date | la date de l'événement (l'heure est ignorée) ; |
Renvois
CalendarEvent
: cet événement d'agenda pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setAllDayDates(startDate, endDate)
Définit les dates de l'événement. L'application de cette méthode transforme un événement standard en événement d'une journée entière.
// 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
startDate | Date | Date de début de l'événement (l'heure est ignorée) |
endDate | Date | Date de fin de l'événement (l'heure est ignorée) |
Renvois
CalendarEvent
: cet événement d'agenda pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setAnyoneCanAddSelf(anyoneCanAddSelf)
Détermine si les utilisateurs qui ne sont pas des invités peuvent s'ajouter à l'événement.
// 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
anyoneCanAddSelf | Boolean | si quelqu'un peut s'inviter |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setColor(color)
Définit la couleur de l'événement d'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'); }
Paramètres
Nom | Type | Description |
---|---|---|
color | String | Index de couleur entier sous forme de chaîne, ou valeur de CalendarApp.EventColor . |
Renvois
CalendarEvent
: cet événement d'agenda, pour le chaînage.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setDescription(description)
Définit la description de l'événement.
// 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
description | String | la nouvelle description |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setGuestsCanInviteOthers(guestsCanInviteOthers)
Détermine si les invités peuvent inviter d'autres personnes.
// 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
guestsCanInviteOthers | Boolean | si les invités peuvent inviter d'autres personnes |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setGuestsCanModify(guestsCanModify)
Détermine si les invités peuvent modifier l'événement.
Paramètres
Nom | Type | Description |
---|---|---|
guestsCanModify | Boolean | si les invités peuvent modifier l'événement |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setGuestsCanSeeGuests(guestsCanSeeGuests)
Détermine si les invités peuvent voir les autres invités.
Paramètres
Nom | Type | Description |
---|---|---|
guestsCanSeeGuests | Boolean | si les invités peuvent voir les autres |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setLocation(location)
Définit le lieu de l'événement.
// 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
location | String | le nouvel emplacement |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setMyStatus(status)
Définit l'état de l'événement (participant ou invité, par exemple) de l'utilisateur effectif.
// 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
status | GuestStatus | le nouvel état, |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
setTag(key, value)
Définit un tag clé-valeur sur l'événement afin de stocker des métadonnées personnalisées.
Paramètres
Nom | Type | Description |
---|---|---|
key | String | la clé de tag |
value | String | la valeur de la balise |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setTime(startTime, endTime)
Définit les dates et heures de début et de fin de l'événement. L'application de cette méthode transforme un événement d'une journée entière en événement standard.
// 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);
Paramètres
Nom | Type | Description |
---|---|---|
startTime | Date | le nouveau début de l'événement |
endTime | Date | la nouvelle fin de l'événement |
Renvois
CalendarEvent
: cet événement d'agenda pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setTitle(title)
Définit le titre de l'événement.
// 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@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, 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'); }
Paramètres
Nom | Type | Description |
---|---|---|
title | String | le nouveau titre |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setVisibility(visibility)
Définit la visibilité de l'événement.
Paramètres
Nom | Type | Description |
---|---|---|
visibility | Visibility |
Renvois
CalendarEvent
: cette CalendarEvent
pour le chaînage
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation associée à un ou plusieurs des champs d'application suivants ou des champs d'application appropriés de l'API REST associée:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds