Class CalendarEvent

CalendarEvent

แสดงกิจกรรมในปฏิทินรายการเดียว

เมธอด

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
addEmailReminder(minutesBefore)CalendarEventเพิ่มการช่วยเตือนทางอีเมลใหม่ไปยังกิจกรรม
addGuest(email)CalendarEventเพิ่มผู้เข้าร่วมในกิจกรรม
addPopupReminder(minutesBefore)CalendarEventเพิ่มการแจ้งเตือนแบบป๊อปอัปใหม่ในกิจกรรม
addSmsReminder(minutesBefore)CalendarEventเพิ่มการแจ้งเตือนทาง SMS ใหม่ไปยังกิจกรรม
anyoneCanAddSelf()Booleanกำหนดว่าผู้ใช้สามารถเพิ่มตนเองเป็นผู้เข้าร่วมในกิจกรรมของปฏิทินได้หรือไม่
deleteEvent()voidลบกิจกรรมในปฏิทิน
deleteTag(key)CalendarEventลบแท็กคีย์/ค่าออกจากเหตุการณ์
getAllDayEndDate()Dateรับวันที่ที่กิจกรรมแบบตลอดวันนี้สิ้นสุดลง
getAllDayStartDate()Dateรับวันที่กิจกรรมแบบตลอดวันนี้เริ่มต้น
getAllTagKeys()String[]รับคีย์ทั้งหมดสำหรับแท็กที่กำหนดไว้ในเหตุการณ์
getColor()Stringแสดงสีของกิจกรรมในปฏิทิน
getCreators()String[]รับผู้สร้างกิจกรรม
getDateCreated()Dateรับข้อมูลวันที่สร้างกิจกรรม
getDescription()Stringรับคำอธิบายกิจกรรม
getEmailReminders()Integer[]รับค่านาทีสำหรับการช่วยเตือนทางอีเมลทั้งหมดสำหรับกิจกรรม
getEndTime()Dateรับข้อมูลวันที่และเวลาที่กิจกรรมในปฏิทินนี้สิ้นสุด
getEventSeries()CalendarEventSeriesรับชุดกิจกรรมที่เกิดซ้ำที่มีกิจกรรมนี้อยู่
getGuestByEmail(email)EventGuestรับผู้เข้าร่วมทางอีเมล
getGuestList()EventGuest[]รับผู้เข้าร่วมกิจกรรม แต่ไม่รวมเจ้าของกิจกรรม
getGuestList(includeOwner)EventGuest[]รับผู้เข้าร่วมกิจกรรม ซึ่งอาจรวมถึงเจ้าของกิจกรรม
getId()Stringรับ iCalUID ที่ไม่ซ้ำกันของเหตุการณ์
getLastUpdated()Dateรับวันที่ที่กิจกรรมได้รับการอัปเดตล่าสุด
getLocation()Stringรับข้อมูลตำแหน่งของกิจกรรม
getMyStatus()GuestStatusดูสถานะกิจกรรม (เช่น เข้าร่วมหรือได้รับเชิญ) ของผู้ใช้ที่มีผล
getOriginalCalendarId()Stringรับรหัสของปฏิทินที่สร้างกิจกรรมนี้ขึ้นในตอนแรก
getPopupReminders()Integer[]รับค่านาทีสำหรับการแจ้งเตือนแบบป๊อปอัปทั้งหมดของกิจกรรม
getSmsReminders()Integer[]รับค่านาทีสำหรับการช่วยเตือนทาง SMS ทั้งหมดสำหรับกิจกรรม
getStartTime()Dateรับข้อมูลวันที่และเวลาที่กิจกรรมในปฏิทินนี้เริ่มต้น
getTag(key)Stringรับค่าแท็กของเหตุการณ์
getTitle()Stringรับชื่อกิจกรรม
getVisibility()Visibilityรับข้อมูลระดับการเข้าถึงกิจกรรม
guestsCanInviteOthers()Booleanกำหนดว่าผู้เข้าร่วมสามารถเชิญผู้เข้าร่วมอื่นได้หรือไม่
guestsCanModify()Booleanกำหนดว่าผู้เข้าร่วมจะแก้ไขกิจกรรมได้หรือไม่
guestsCanSeeGuests()Booleanกำหนดว่าผู้เข้าร่วมจะเห็นผู้เข้าร่วมคนอื่นๆ หรือไม่
isAllDayEvent()Booleanกำหนดว่าเป็นกิจกรรมตลอดทั้งวันหรือไม่
isOwnedByMe()Booleanกำหนดว่าคุณเป็นเจ้าของกิจกรรมหรือไม่
isRecurringEvent()Booleanกำหนดว่ากิจกรรมเป็นส่วนหนึ่งของชุดกิจกรรมหรือไม่
removeAllReminders()CalendarEventลบการแจ้งเตือนทั้งหมดออกจากกิจกรรม
removeGuest(email)CalendarEventนำผู้เข้าร่วมออกจากกิจกรรม
resetRemindersToDefault()CalendarEventรีเซ็ตการช่วยเตือนโดยใช้การตั้งค่าเริ่มต้นของปฏิทิน
setAllDayDate(date)CalendarEventกำหนดวันที่ของกิจกรรม
setAllDayDates(startDate, endDate)CalendarEventกำหนดวันที่ของกิจกรรม
setAnyoneCanAddSelf(anyoneCanAddSelf)CalendarEventตั้งค่าว่าผู้ที่ไม่ใช่ผู้เข้าร่วมจะเพิ่มตนเองในกิจกรรมได้หรือไม่
setColor(color)CalendarEventตั้งค่าสีของกิจกรรมในปฏิทิน
setDescription(description)CalendarEventตั้งค่าคำอธิบายกิจกรรม
setGuestsCanInviteOthers(guestsCanInviteOthers)CalendarEventตั้งค่าว่าผู้เข้าร่วมสามารถเชิญผู้เข้าร่วมอื่นได้หรือไม่
setGuestsCanModify(guestsCanModify)CalendarEventตั้งค่าว่าผู้เข้าร่วมจะแก้ไขกิจกรรมได้หรือไม่
setGuestsCanSeeGuests(guestsCanSeeGuests)CalendarEventตั้งค่าว่าผู้เข้าร่วมจะเห็นผู้เข้าร่วมรายอื่นหรือไม่
setLocation(location)CalendarEventตั้งค่าสถานที่ของกิจกรรม
setMyStatus(status)CalendarEventตั้งค่าสถานะกิจกรรม (เช่น เข้าร่วมหรือได้รับเชิญ) ของผู้ใช้ที่มีผล
setTag(key, value)CalendarEventตั้งค่าแท็กคีย์/ค่าในเหตุการณ์เพื่อจัดเก็บข้อมูลเมตาที่กำหนดเอง
setTime(startTime, endTime)CalendarEventตั้งค่าวันที่และเวลาสำหรับการเริ่มต้นและสิ้นสุดของกิจกรรม
setTitle(title)CalendarEventตั้งชื่อกิจกรรม
setVisibility(visibility)CalendarEventตั้งค่าระดับการเข้าถึงกิจกรรม

เอกสารโดยละเอียด

addEmailReminder(minutesBefore)

เพิ่มการช่วยเตือนทางอีเมลใหม่ไปยังกิจกรรม การช่วยเตือนต้องมีความยาวอย่างน้อย 5 นาทีแต่ไม่เกิน 4 นาที สัปดาห์ (40320 นาที) ก่อนเริ่มกิจกรรม

// 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);

พารามิเตอร์

ชื่อประเภทคำอธิบาย
minutesBeforeIntegerจำนวนนาทีก่อนกิจกรรม

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การขว้าง

Error — หากมีการช่วยเตือนมากกว่า 5 ครั้งในกิจกรรมนั้น หรือไม่ได้ระบุเวลา ภายในช่วงทางกฎหมาย

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

addGuest(email)

เพิ่มผู้เข้าร่วมในกิจกรรม

// 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);
  }
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
emailStringอีเมลของผู้เข้าร่วม

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำสายโซ่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

addPopupReminder(minutesBefore)

เพิ่มการแจ้งเตือนแบบป๊อปอัปใหม่ในกิจกรรม การแจ้งเตือนต้องมีความยาวอย่างน้อย 5 นาที และ ล่วงหน้าไม่เกิน 4 สัปดาห์ (40,320 นาที) ก่อนกิจกรรมเริ่ม

// 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);

พารามิเตอร์

ชื่อประเภทคำอธิบาย
minutesBeforeIntegerจำนวนนาทีก่อนกิจกรรม

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

addSmsReminder(minutesBefore)

เพิ่มการแจ้งเตือนทาง SMS ใหม่ไปยังกิจกรรม การช่วยเตือนต้องมีความยาวอย่างน้อย 5 นาทีแต่ไม่เกิน 4 นาที สัปดาห์ (40320 นาที) ก่อนเริ่มกิจกรรม

พารามิเตอร์

ชื่อประเภทคำอธิบาย
minutesBeforeIntegerจำนวนนาทีก่อนกิจกรรม

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การขว้าง

Error — หากมีการช่วยเตือนมากกว่า 5 ครั้งในกิจกรรมนั้น หรือไม่ได้ระบุเวลา ภายในช่วงทางกฎหมาย

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

anyoneCanAddSelf()

กำหนดว่าผู้ใช้สามารถเพิ่มตนเองเป็นผู้เข้าร่วมในกิจกรรมของปฏิทินได้หรือไม่

// 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());

รีเทิร์น

Booleantrue หากผู้ที่ไม่ใช่ผู้เข้าร่วมเพิ่มตนเองลงในกิจกรรมได้ false หากไม่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

deleteEvent()

ลบกิจกรรมในปฏิทิน

// 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();

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

deleteTag(key)

ลบแท็กคีย์/ค่าออกจากเหตุการณ์

พารามิเตอร์

ชื่อประเภทคำอธิบาย
keyStringคีย์แท็ก

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getAllDayEndDate()

รับวันที่ที่กิจกรรมแบบตลอดวันนี้สิ้นสุดลง (หากไม่ใช่กิจกรรมตลอดทั้งวัน วิธีนี้มีข้อยกเว้น) Date ที่แสดงผลแสดงถึงเที่ยงคืนเวลา เริ่มต้นของวันหลังจากที่กิจกรรมสิ้นสุดลงในเขตเวลาของสคริปต์ วิธีใช้ เขตเวลาของปฏิทิน โปรดโทร 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);

รีเทิร์น

Date — วันที่สิ้นสุดของกิจกรรมเต็มวันในปฏิทินนี้

การขว้าง

Error — หากกิจกรรมนี้ไม่ใช่กิจกรรมตลอดทั้งวัน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getAllDayStartDate()

รับวันที่กิจกรรมแบบตลอดวันนี้เริ่มต้น (ถ้าไม่ใช่กิจกรรมเต็มวัน วิธีนี้จะมีข้อยกเว้น) Date ที่แสดงผลแสดงถึงเที่ยงคืนเวลา เวลาเริ่มต้นของวันที่กิจกรรมเริ่มต้นในเขตเวลาของสคริปต์ วิธีใช้ เขตเวลาของปฏิทิน โปรดโทร 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);

รีเทิร์น

Date — วันที่เริ่มต้นของกิจกรรมในปฏิทินตลอดทั้งวันนี้

การขว้าง

Error — หากกิจกรรมนี้ไม่ใช่กิจกรรมตลอดทั้งวัน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getAllTagKeys()

รับคีย์ทั้งหมดสำหรับแท็กที่กำหนดไว้ในเหตุการณ์

รีเทิร์น

String[] — อาร์เรย์ของคีย์สตริง

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getColor()

แสดงสีของกิจกรรมในปฏิทิน

// 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);

รีเทิร์น

String — ค่าแทนสตริงของสีเหตุการณ์ เป็นดัชนี (1-11) ของค่าจาก CalendarApp.EventColor

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getCreators()

รับผู้สร้างกิจกรรม

// 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());

รีเทิร์น

String[] — อีเมลผู้สร้างกิจกรรม

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getDateCreated()

รับข้อมูลวันที่สร้างกิจกรรม คุณต้องมีสิทธิ์เข้าถึงปฏิทิน

// 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');
}

รีเทิร์น

Date — วันที่สร้าง

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getDescription()

รับคำอธิบายกิจกรรม คุณต้องมีสิทธิ์แก้ไขปฏิทิน

// 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');
}

รีเทิร์น

String — คำอธิบาย

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getEmailReminders()

รับค่านาทีสำหรับการช่วยเตือนทางอีเมลทั้งหมดสำหรับกิจกรรม คุณต้องมีสิทธิ์แก้ไข ปฏิทิน

// 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');
}

รีเทิร์น

Integer[] — อาร์เรย์ที่แต่ละค่าตรงกับจำนวนนาทีก่อนเหตุการณ์ที่ ทริกเกอร์การช่วยเตือน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getEndTime()

รับข้อมูลวันที่และเวลาที่กิจกรรมในปฏิทินนี้สิ้นสุด คุณต้องมีสิทธิ์เข้าถึงปฏิทิน สำหรับกิจกรรมที่ไม่ใช่กิจกรรมตลอดทั้งวัน นี่คือเวลาทันทีที่มีการกำหนดกิจกรรมไว้ที่ สิ้นสุด นี่หมายถึงเที่ยงคืนสำหรับกิจกรรมตลอดทั้งวันซึ่งเก็บเฉพาะวันที่สิ้นสุด (ไม่ใช่วันที่และเวลา) ในช่วงต้นวันหลังจากที่กิจกรรมสิ้นสุดลงในเขตเวลาของปฏิทิน ช่วงเวลานี้ ช่วยให้เปรียบเทียบเวลาสิ้นสุดของกิจกรรมทุกประเภทได้อย่างมีความหมาย แต่ไม่ได้ จะต้องคงวันของปีเดิมไว้และไม่มีการแก้ไข

สำหรับกิจกรรมตลอดทั้งวัน getAllDayEndDate() ควร จะเรียกใช้วิธีนี้เสมอ

// 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');
}

รีเทิร์น

Date — เวลาสิ้นสุดของกิจกรรมนี้ในปฏิทิน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getEventSeries()

รับชุดกิจกรรมที่เกิดซ้ำที่มีกิจกรรมนี้อยู่ คุณต้องมีสิทธิ์เข้าถึง ปฏิทิน ระบบแสดงผลออบเจ็กต์ CalendarEventSeries แม้ว่าเหตุการณ์นี้จะไม่ได้อยู่ในกลุ่ม เพื่อให้คุณเพิ่มการตั้งค่าการเกิดซ้ำใหม่ได้

// 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');
}

รีเทิร์น

CalendarEventSeries — ชุดกิจกรรมที่เป็นเจ้าของกิจกรรมนี้ หรือชุดกิจกรรมใหม่หากยังไม่มี ลงในชุด

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getGuestByEmail(email)

รับผู้เข้าร่วมทางอีเมล

// 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());
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
emailStringที่อยู่ของผู้เข้าร่วม

รีเทิร์น

EventGuest — ผู้เข้าร่วมหรือค่าว่างหากอีเมลไม่ตรงกับผู้เข้าร่วม

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getGuestList()

รับผู้เข้าร่วมกิจกรรม แต่ไม่รวมเจ้าของกิจกรรม

// 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());
}

รีเทิร์น

EventGuest[] — อาร์เรย์ของผู้มาเยือน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getGuestList(includeOwner)

รับผู้เข้าร่วมกิจกรรม ซึ่งอาจรวมถึงเจ้าของกิจกรรม

// 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());
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
includeOwnerBooleanจะรวมเจ้าของเป็นผู้มาเยือนหรือไม่

รีเทิร์น

EventGuest[] — อาร์เรย์ของผู้มาเยือน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getId()

รับ iCalUID ที่ไม่ซ้ำกันของเหตุการณ์ โปรดทราบว่า iCalUID และเหตุการณ์ id ที่ใช้โดย ปฏิทิน v3 API และบริการขั้นสูงของปฏิทินไม่เหมือนกันและ ไม่สามารถใช้แทนกันได้ ความแตกต่างอย่างหนึ่งในความหมายของคำเหล่านี้ก็คือ ในกิจกรรมที่เกิดซ้ำ ทุกรายการของเหตุการณ์หนึ่งมี ids ที่แตกต่างกันในขณะที่ทั้งหมดใช้ iCalUID เดียวกัน

// 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());

รีเทิร์น

String — iCalUID ของเหตุการณ์

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getLastUpdated()

รับวันที่ที่กิจกรรมได้รับการอัปเดตล่าสุด

// 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);

รีเทิร์น

Date — วันที่อัปเดตล่าสุด

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getLocation()

รับข้อมูลตำแหน่งของกิจกรรม

// 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');
}

รีเทิร์น

String — สถานที่จัดกิจกรรม

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getMyStatus()

ดูสถานะกิจกรรม (เช่น เข้าร่วมหรือได้รับเชิญ) ของผู้ใช้ที่มีผล แสดงผลเสมอ GuestStatus.OWNER หากผู้ใช้ที่มีผลเป็นเจ้าของกิจกรรม

// 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');
}

รีเทิร์น

GuestStatus — สถานะ

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getOriginalCalendarId()

รับรหัสของปฏิทินที่สร้างกิจกรรมนี้ขึ้นในตอนแรก

// 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');
}

รีเทิร์น

String — รหัสของปฏิทินเดิม

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getPopupReminders()

รับค่านาทีสำหรับการแจ้งเตือนแบบป๊อปอัปทั้งหมดของกิจกรรม

  // 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');
}

รีเทิร์น

Integer[] — อาร์เรย์ที่แต่ละค่าตรงกับจำนวนนาทีก่อนเหตุการณ์ที่ ทริกเกอร์การช่วยเตือน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getSmsReminders()

รับค่านาทีสำหรับการช่วยเตือนทาง SMS ทั้งหมดสำหรับกิจกรรม

รีเทิร์น

Integer[] — อาร์เรย์ที่แต่ละค่าตรงกับจำนวนนาทีก่อนเหตุการณ์ที่ ทริกเกอร์การช่วยเตือน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getStartTime()

รับข้อมูลวันที่และเวลาที่กิจกรรมในปฏิทินนี้เริ่มต้น สำหรับกิจกรรมที่ไม่ใช่กิจกรรมตลอดทั้งวัน ค่านี้ คือช่วงเวลาที่เหตุการณ์ถูกกำหนดให้เริ่มต้น สำหรับกิจกรรมตลอดทั้งวัน เก็บวันที่เริ่มต้น (ไม่ใช่วันที่และเวลา) ซึ่งก็คือเที่ยงคืนของช่วงต้นวันที่ซึ่ง กิจกรรมจะเริ่มต้นในเขตเวลาของปฏิทิน ซึ่งช่วยให้สามารถเปรียบเทียบ เวลาเริ่มต้นสำหรับกิจกรรมทุกประเภท แต่ไม่ได้เก็บต้นฉบับไว้ วันของปีที่ไม่มีการแก้ไข

สำหรับกิจกรรมตลอดทั้งวัน getAllDayStartDate() ควร มักจะถูกเรียกใช้มากกว่าวิธีนี้

// 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);

รีเทิร์น

Date — เวลาเริ่มต้นของกิจกรรมนี้ในปฏิทิน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getTag(key)

รับค่าแท็กของเหตุการณ์

พารามิเตอร์

ชื่อประเภทคำอธิบาย
keyStringคีย์

รีเทิร์น

String — ค่าแท็ก

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getTitle()

รับชื่อกิจกรรม

// 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');
}

รีเทิร์น

String — ชื่อ

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

getVisibility()

รับข้อมูลระดับการเข้าถึงกิจกรรม

// 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');
}

รีเทิร์น

Visibility — ค่าการแสดงผล

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

guestsCanInviteOthers()

กำหนดว่าผู้เข้าร่วมสามารถเชิญผู้เข้าร่วมอื่นได้หรือไม่

// 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');
}

รีเทิร์น

Booleantrue หากผู้เข้าร่วมสามารถเชิญคนอื่นได้ false หากไม่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

guestsCanModify()

กำหนดว่าผู้เข้าร่วมจะแก้ไขกิจกรรมได้หรือไม่

// 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');
}

รีเทิร์น

Booleantrue หากผู้เข้าร่วมแก้ไขกิจกรรมได้ false หากไม่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

guestsCanSeeGuests()

กำหนดว่าผู้เข้าร่วมจะเห็นผู้เข้าร่วมคนอื่นๆ หรือไม่

// 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');
}

รีเทิร์น

Booleantrue หากผู้เข้าร่วมมองเห็นผู้เข้าร่วมรายอื่นได้ false หากไม่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

isAllDayEvent()

กำหนดว่าเป็นกิจกรรมตลอดทั้งวันหรือไม่

// 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());

รีเทิร์น

Booleantrue หากเป็นกิจกรรมตลอดทั้งวัน false หากไม่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

isOwnedByMe()

กำหนดว่าคุณเป็นเจ้าของกิจกรรมหรือไม่

// 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');
}

รีเทิร์น

Booleantrue หากกิจกรรมเป็นของผู้ใช้ที่มีผล false หากไม่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

isRecurringEvent()

กำหนดว่ากิจกรรมเป็นส่วนหนึ่งของชุดกิจกรรมหรือไม่

// 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');
}

รีเทิร์น

Booleantrue หากกิจกรรมเป็นส่วนหนึ่งของชุดกิจกรรม false หากไม่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

removeAllReminders()

ลบการแจ้งเตือนทั้งหมดออกจากกิจกรรม

// 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');
}

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

removeGuest(email)

นำผู้เข้าร่วมออกจากกิจกรรม

// 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);
  }
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
emailStringอีเมลของผู้เข้าร่วม

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

resetRemindersToDefault()

รีเซ็ตการช่วยเตือนโดยใช้การตั้งค่าเริ่มต้นของปฏิทิน

// 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');
}

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setAllDayDate(date)

กำหนดวันที่ของกิจกรรม การใช้วิธีนี้จะเปลี่ยนกิจกรรมปกติเป็นกิจกรรมตลอดทั้งวัน

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
dateDateวันที่ของเหตุการณ์ (ไม่สนใจเวลา)

รีเทิร์น

CalendarEvent — CalendarEvent สำหรับห่วงโซ่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setAllDayDates(startDate, endDate)

กำหนดวันที่ของกิจกรรม การใช้วิธีนี้จะเปลี่ยนกิจกรรมปกติเป็นกิจกรรมตลอดทั้งวัน กิจกรรม

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
startDateDateวันที่ที่กิจกรรมเริ่มต้น (ไม่สนใจเวลา)
endDateDateวันที่ที่กิจกรรมสิ้นสุดลง (ไม่สนใจเวลา)

รีเทิร์น

CalendarEvent — CalendarEvent สำหรับห่วงโซ่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setAnyoneCanAddSelf(anyoneCanAddSelf)

ตั้งค่าว่าผู้ที่ไม่ใช่ผู้เข้าร่วมจะเพิ่มตนเองในกิจกรรมได้หรือไม่

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
anyoneCanAddSelfBooleanทุกคนสามารถเชิญตัวเอง

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setColor(color)

ตั้งค่าสีของกิจกรรมในปฏิทิน

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
colorStringดัชนีสีแบบจำนวนเต็มเป็นสตริง หรือค่าจาก CalendarApp.EventColor

รีเทิร์น

CalendarEvent — กิจกรรมในปฏิทินนี้สำหรับเชนธุรกิจ

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setDescription(description)

ตั้งค่าคำอธิบายกิจกรรม

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
descriptionStringคำอธิบายใหม่

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setGuestsCanInviteOthers(guestsCanInviteOthers)

ตั้งค่าว่าผู้เข้าร่วมสามารถเชิญผู้เข้าร่วมอื่นได้หรือไม่

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
guestsCanInviteOthersBooleanผู้เข้าร่วมสามารถเชิญบุคคลอื่นได้หรือไม่

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setGuestsCanModify(guestsCanModify)

ตั้งค่าว่าผู้เข้าร่วมจะแก้ไขกิจกรรมได้หรือไม่

พารามิเตอร์

ชื่อประเภทคำอธิบาย
guestsCanModifyBooleanผู้เข้าร่วมจะแก้ไขกิจกรรมได้หรือไม่

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setGuestsCanSeeGuests(guestsCanSeeGuests)

ตั้งค่าว่าผู้เข้าร่วมจะเห็นผู้เข้าร่วมรายอื่นหรือไม่

พารามิเตอร์

ชื่อประเภทคำอธิบาย
guestsCanSeeGuestsBooleanผู้เข้าร่วมจะเห็นผู้อื่นได้หรือไม่

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setLocation(location)

ตั้งค่าสถานที่ของกิจกรรม

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
locationStringสถานที่ใหม่

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setMyStatus(status)

ตั้งค่าสถานะกิจกรรม (เช่น เข้าร่วมหรือได้รับเชิญ) ของผู้ใช้ที่มีผล

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
statusGuestStatusสถานะใหม่

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setTag(key, value)

ตั้งค่าแท็กคีย์/ค่าในเหตุการณ์เพื่อจัดเก็บข้อมูลเมตาที่กำหนดเอง

พารามิเตอร์

ชื่อประเภทคำอธิบาย
keyStringคีย์แท็ก
valueStringค่าแท็ก

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setTime(startTime, endTime)

ตั้งค่าวันที่และเวลาสำหรับการเริ่มต้นและสิ้นสุดของกิจกรรม การใช้วิธีการนี้จะเปลี่ยนแปลง กิจกรรมตลอดทั้งวันเป็นกิจกรรมปกติ

// 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);

พารามิเตอร์

ชื่อประเภทคำอธิบาย
startTimeDateการเริ่มต้นกิจกรรมใหม่
endTimeDateตอนจบใหม่ของกิจกรรม

รีเทิร์น

CalendarEvent — CalendarEvent สำหรับห่วงโซ่

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setTitle(title)

ตั้งชื่อกิจกรรม

// 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');
}

พารามิเตอร์

ชื่อประเภทคำอธิบาย
titleStringชื่อใหม่

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setVisibility(visibility)

ตั้งค่าระดับการเข้าถึงกิจกรรม

พารามิเตอร์

ชื่อประเภทคำอธิบาย
visibilityVisibility

รีเทิร์น

CalendarEventCalendarEvent นี้สำหรับการทำเชน

การให้สิทธิ์

สคริปต์ที่ใช้เมธอดนี้จำเป็นต้องได้รับการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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