简体   繁体   English

如何将 Google Meet 和 Google Meet live stream 网址导出到 Google 表格?

[英]How to export Google Meet and Google Meet live stream urls to Google sheet?

So I'm working off an App Script template that allows you to find and export your Google Calendar for a range of dates to a Google Spreadsheet for further reporting or processing (hosted at https://www.cloudbakers.com/blog/export-google-calendar-entries-to-a-google-spreadsheet ).因此,我正在开发一个 App Script 模板,该模板允许您查找 Google 日历并将其导出为 Google 电子表格,以便进一步报告或处理(托管在https://www.cloudbakers.com/blog/export -google-calendar-entries-to-a-google-spreadsheet )。 I have it running just fine in my copy, but I want to add the urls for both the Google Meet video conference and the Google Meet Livestream to the columns that are output for each calendar event.我的副本中运行得很好,但我想将 Google Meet 视频会议和 Google Meet Livestream 的 URL 添加到每个日历事件的 output 列中。 At my company these would typically be listed as the first and last values in conferenceData.entryPoints[].uri.在我的公司,这些通常被列为 ConferenceData.entryPoints[].uri 中的第一个和最后一个值。 I tried:我试过了:

var details=[[mycal,events[i].getTitle(), events[i].getDescription(), events[i].getLocation(), events[i].getStartTime(), events[i].getEndTime(), myformula_placeholder, ('' + events[i].getVisibility()), events[i].getDateCreated(), events[i].getLastUpdated(), events[i].getMyStatus(), events[i].getCreators(), events[i].isAllDayEvent(), events[i].isRecurringEvent(), events[i].conferenceData.entryPoints.uri]];

and get "TypeError: Cannot read property "entryPoints" from undefined".并获得“TypeError:无法从未定义中读取属性“entryPoints””。 Re-running with just events[i].conferenceData at the end, indeed just prints "undefined" in my new column in my sheet.最后只使用 events[i].conferenceData 重新运行,实际上只是在工作表的新列中打印“未定义”。

Any ideas on what I'm missing here?关于我在这里缺少什么的任何想法? I'm an Apps Scripts noob so not having much success at all trying to troubleshoot this on my own.我是一个 Apps Scripts 菜鸟,所以我自己尝试解决这个问题并没有取得太大的成功。

When you use CalendarApp.getEvents(startTime, endTime, options) to get all the events within the given time range, It will return an array of CalendarEvent object.当您使用CalendarApp.getEvents(startTime, endTime, options)获取给定时间范围内的所有事件时,它将返回一个CalendarEvent数组 object。 CalendarEvent object doesn't have conferenceData method. CalendarEvent object 没有conferenceData方法。 You can check the list of available CalendarEvent methods on the reference link provided.您可以在提供的参考链接上查看可用的 CalendarEvent 方法列表。

There is no CalendarEvent method you can use to obtain the Google Meet and Google Live Stream URLs.没有可用于获取 Google Meet 和 Google Live Stream URL 的CalendarEvent方法。 You need to use Advanced Calendar Service to obtain this URLs.您需要使用高级日历服务来获取此 URL。


Pre-requisite: Enable advanced services先决条件: 启用高级服务

在此处输入图像描述

在此处输入图像描述


Sample Code:示例代码:

  // Create a header record on the current spreadsheet in cells A1:N1 - Match the number of entries in the "header=" to the last parameter
  // of the getRange entry below
  var header = [["Calendar Address", "Event Title", "Event Description", "Event Location", "Event Start", "Event End", "Calculated Duration", "Visibility", "Date Created", "Last Updated", "MyStatus", "Created By", "All Day Event", "Recurring Event", "Meet Link", "Live Stream"]]
  var range = sheet.getRange(1,1,1,16);
  range.setValues(header);

    
  // Loop through all calendar events found and write them out starting on calulated ROW 2 (i+2)
  for (var i=0;i<events.length;i++) {
    var row=i+2;
    var myformula_placeholder = '';
    // Matching the "header=" entry above, this is the detailed row entry "details=", and must match the number of entries of the GetRange entry below
    // NOTE: I've had problems with the getVisibility for some older events not having a value, so I've had do add in some NULL text to make sure it does not error

    var details=[[mycal,events[i].getTitle(), events[i].getDescription(), events[i].getLocation(), events[i].getStartTime(), events[i].getEndTime(), myformula_placeholder, ('' + events[i].getVisibility()), events[i].getDateCreated(), events[i].getLastUpdated(), events[i].getMyStatus(), events[i].getCreators(), events[i].isAllDayEvent(), events[i].isRecurringEvent(), "None", "None"]];
    
    //Add Meet link
    var eventId = events[i].getId().replace("@google.com","");
    var currentEvent = Calendar.Events.get(mycal,eventId);
    if(currentEvent.conferenceData != null){
      //Update Meet link
      details[0][14] = currentEvent.conferenceData.entryPoints[0].uri;

      //Update Live Stream
      if(currentEvent.conferenceData.entryPoints.length > 1){
        details[0][15] = currentEvent.conferenceData.entryPoints[currentEvent.conferenceData.entryPoints.length - 1].uri;
      }
    }
    var range=sheet.getRange(row,1,1,16);
    range.setValues(details);

    // Writing formulas from scripts requires that you write the formulas separate from non-formulas
    // Write the formula out for this specific row in column 7 to match the position of the field myformula_placeholder from above: foumula over columns F-E for time calc
    var cell=sheet.getRange(row,7);
    cell.setFormula('=(HOUR(F' +row+ ')+(MINUTE(F' +row+ ')/60))-(HOUR(E' +row+ ')+(MINUTE(E' +row+ ')/60))');
    cell.setNumberFormat('.00');

  }

What it does?它能做什么?

  1. Add additional sheet header ("Meet Link" and "Live Stream") in your header variableheader变量中添加附加表 header(“Meet Link”和“Live Stream”)
  2. Add additional default value for meet link and live stream link in your details variable在您的details变量中为 meet 链接和 live stream 链接添加额外的默认值
  3. Get the calendar event id from the iCalUID of the event.从事件的 iCalUID 获取日历事件 ID。 CalendarEvent.getId() returns an iCalUID of the event. CalendarEvent.getId()返回事件的 iCalUID。 We just need to remove "@google.com" in the iCalUID to obtain the event id.我们只需要删除 iCalUID 中的“@google.com”即可获取事件 ID。

Note that the iCalUID and the event id used by the Calendar v3 API and Calendar advanced service are not identical and cannot be used interchangebly请注意,Calendar v3 API 和 Calendar 高级服务使用的 iCalUID 和事件 ID 不相同,不能互换使用

  1. Use Calendar.Events.get(calendarId: string, eventId: string) to get the event resource which contains the conferenceData (if available)使用Calendar.Events.get(calendarId: string, eventId: string)获取包含conferenceData数据的事件资源(如果可用)
  2. Check if conferenceData exist, update the details variable based on the entryPoints[] parameter.检查conferenceData是否存在,根据entryPoints[]参数更新details变量。
  3. Write the event details to the active sheet将事件详细信息写入活动工作表

Output: Output:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google 工作表 + 应用脚本:如果满足条件,则重命名每个工作表 - Google sheet + App Script : Rename every sheet if it meet criteria 如何使用 Google App Scripts 在 Classroom 中将 Meet 代码列表获取到 Google Sheet - How to get the list of Meet codes to Google Sheet in Classroom with Google App Scripts 如何生成 Google Meet Participants 的出席报告 - How to generate the attendance report of Google Meet Participants 自动 email 满足特定条件的所有行 google sheet - Auto email all rows of google sheet that meet a certain condition 如何在 javascript 中通过谷歌日历 api 获得谷歌见面链接? - How to get Google meet link thru google calendar api in javascript? 如何在定期的 google meet 中查看学生的出勤情况? - How can I check student attendance in recurring google meet's? 如何使用 Google Apps 脚本将 Google Meet 链接添加到新的 Google 日历活动? - How to add a Google Meet link to a new Google Calendar Event using a Google Apps Script? 在 Google 表格中复制符合日期的行 - Copy rows that meet a date in Google Sheets 在 Google Scripts 中生成符合条件的表格列表? - Generate a list of Sheets that meet a condition in Google Scripts? 查找 Google Meet 特定开始时间以参加会议 - Find Google Meet specific startTime to take attendance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM