Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为Google API Calendar.Events.patch定义日历ID_Javascript_Google Apps Script_Calendar - Fatal编程技术网

Javascript 为Google API Calendar.Events.patch定义日历ID

Javascript 为Google API Calendar.Events.patch定义日历ID,javascript,google-apps-script,calendar,Javascript,Google Apps Script,Calendar,我试着用下面的代码更新GoogleCalender事件 我不想在我的主日历中修补事件,但在我的birhtday提醒日历中的所有事件(我将联系人的所有生日同步到此日历),因此我尝试了一点,但没有成功 我试过: var calendarId = CalendarApp.getCalendarById("example@group.calendar.google.com") var calendarId = 'example@group.calendar.google.com'

我试着用下面的代码更新GoogleCalender事件

我不想在我的主日历中修补事件,但在我的birhtday提醒日历中的所有事件(我将联系人的所有生日同步到此日历),因此我尝试了一点,但没有成功

我试过:

var calendarId = CalendarApp.getCalendarById("example@group.calendar.google.com")
var calendarId = 'example@group.calendar.google.com'
var calendarId = 'example'
什么都没用。我总是得到:

ReferenceError: Calendar is not defined

除了主日历之外,有人知道这是如何与其他日历一起工作的吗?

尝试以下方法以获取日历id:

function displayCalendarInfo() {
  var cals=CalendarApp.getAllCalendars();
  var s='Calendar Information';
  for(var i=0;i<cals.length;i++) {
    s+=Utilities.formatString('<br />Name: %s Id: %s', cals[i].getName(),cals[i].getId());
  }
  s+='<br /><input type="button" value="Close" onClick="google.script.host.close();" />';
  var ui=HtmlService.createHtmlOutput(s).setWidth(1200).setHeight(450);
  SpreadsheetApp.getUi().showModelessDialog(ui, 'Calendar Data');
}
函数displayCalendarInfo(){
var cals=CalendarApp.getAllCalendars();
var s='日历信息';

对于(var i=0;i,由于这是一个参考错误,我认为这与参考问题中使用的缺少全局类
Calendar
有关


如图所示,通过启用“使用前”可以解决此问题(请注意,这使用的是旧编辑器,如果使用的是最新的编辑器,则可以从UI临时切换到旧编辑器).

我在“设置”下的Web UI中看到的日历ID是否有任何不同?是否有第二个不同的ID?对于从联系人到自定义日历的同步,我需要该ID,并且该ID正在工作。calendar.events.patch的相同ID不起作用。这让我感到困惑。没有第二个ID,您应该能够使用日历ID在web ui中。此
var calendarId='0example@group.calendar.google.com“
应该可以工作。问题是,@Abdellah Hariti提到,
日历
对象没有定义。您需要启用高级日历服务才能使用
日历
对象
function displayCalendarInfo() {
  var cals=CalendarApp.getAllCalendars();
  var s='Calendar Information';
  for(var i=0;i<cals.length;i++) {
    s+=Utilities.formatString('<br />Name: %s Id: %s', cals[i].getName(),cals[i].getId());
  }
  s+='<br /><input type="button" value="Close" onClick="google.script.host.close();" />';
  var ui=HtmlService.createHtmlOutput(s).setWidth(1200).setHeight(450);
  SpreadsheetApp.getUi().showModelessDialog(ui, 'Calendar Data');
}