Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.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 向活动中添加多个日历ID和与会者电子邮件_Javascript_Google Apps Script_Google Sheets_Google Calendar Api_Integration - Fatal编程技术网

Javascript 向活动中添加多个日历ID和与会者电子邮件

Javascript 向活动中添加多个日历ID和与会者电子邮件,javascript,google-apps-script,google-sheets,google-calendar-api,integration,Javascript,Google Apps Script,Google Sheets,Google Calendar Api,Integration,我有一个脚本,可以根据我们已有的谷歌工作表时间表,自动化我们的日历。它确实可以将事件添加到特定的日历中,但我想将单独的日历添加到脚本中,并自动添加一个google组作为活动的来宾,以便像正常的google日历事件一样发出通知 function scheduleShifts() { /** Task 1) Open the Event Calendar. **/ var spreadsheet = SpreadsheetApp.getActive(); var calendarID =

我有一个脚本,可以根据我们已有的谷歌工作表时间表,自动化我们的日历。它确实可以将事件添加到特定的日历中,但我想将单独的日历添加到脚本中,并自动添加一个google组作为活动的来宾,以便像正常的google日历事件一样发出通知

   function scheduleShifts() {
/**
  Task 1) Open the Event Calendar.
**/
var spreadsheet = SpreadsheetApp.getActive();
var calendarID = spreadsheet.getRange("C2").getValue();
var eventCal = CalendarApp.getCalendarById(calendarID);

/**
  Task 2) Pull each shift information into the code, in
  a form that the code can understand. 
**/
var signups = spreadsheet.getRange("A5:C100").getValues();

/**
    [
      [11/9/2019 0:00:00,11/10/2019 0:00:00,Werdah On-Call],
      [11/10/2019 0:00:00,11/11/2019 0:00:00,Lucas On-Call],
      [11/16/2019 0:00:00,11/17/2019 0:00:00,Aiden On-Call],
      [11/17/2019 0:00:00,11/18/2019 0:00:00,Werdah On-Call],
      [11/23/2019 0:00:00,11/24/2019 0:00:00,Mayra On-Call],
      [11/24/2019 0:00:00,11/25/2019 0:00:00,Kyle On-Call],
      [11/30/2019 0:00:00,12/1/2019 0:00:00,Cavan On-Call],
      [12/1/2019 0:00:00,12/2/2019 0:00:00,Adam On-Call],
      [12/7/2019 0:00:00,12/8/2019 0:00:00,Hillary On-Call],
      [12/8/2019 0:00:00,12/9/2019 0:00:00,Melissa Pino On-Call],
      [12/14/2019 0:00:00,12/15/2019 0:00:00,Kristi On-Call],
      [12/15/2019 0:00:00,12/16/2019 0:00:00,Kevin On-Call],
      [12/21/2019 0:00:00,12/22/2019 0:00:00,Alice On-Call],
      [12/22/2019 0:00:00,12/23/2019 0:00:00,Carro On-Call],
      [12/28/2019 0:00:00,12/29/2019 0:00:00,Sruthi On-Call],
      [12/29/2019 0:00:00,12/30/2019 0:00:00,Tara On-Call]
    ]  
**/

/**
  Task 3) Do the work!
**/
for (x=0; x<signups.length; x++) {

var shift = signups[x];

var startTime = shift[0];
var endTime = shift[1];
var oncall = shift[2];

eventCal.createEvent(oncall, startTime, endTime);
  }
}

/**
  Task 4) Make it easy to ue.
**/
function onOpen(){
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sync to Calendar')
      .addItem('Schedule shifts now','scheduleShifts')
      .addToUi();
}
函数调度移位(){
/**
任务1)打开事件日历。
**/
var电子表格=SpreadsheetApp.getActive();
var calendarID=spreadsheet.getRange(“C2”).getValue();
var eventCal=CalendarApp.getCalendarById(calendarID);
/**
任务2)将每个班次信息拉入代码,以
代码可以理解的形式。
**/
var signups=spreadsheet.getRange(“A5:C100”).getValues();
/**
[
[2019年9月11日0:00:00,2019年10月11日0:00:00,Werdah待命],
[2019年10月11日0:00:00,2019年11月11日0:00:00,卢卡斯待命],
[2019年11月16日0:00:00,2019年11月17日0:00:00,艾登待命],
[2019年11月17日0:00:00,2019年11月18日0:00:00,Werdah待命],
[2019年11月23日0:00:00,2019年11月24日0:00:00,玛拉待命],
[2019年11月24日0:00:00,2019年11月25日0:00:00,凯尔待命],
[2019年11月30日0:00:00,2019年12月1日0:00:00,卡万待命],
[2019年12月1日0:00:00,2019年12月2日0:00:00,亚当待命],
[2019年12月7日0:00:00,2019年12月8日0:00:00,希拉里待命],
[2019年12月8日0:00:00,2019年12月9日0:00:00,梅丽莎·皮诺待命],
[2019年12月14日0:00:00,2019年12月15日0:00:00,克里斯蒂待命],
[2019年12月15日0:00:00,2019年12月16日0:00:00,凯文待命],
[2019年12月21日0:00:00,2019年12月22日0:00:00,Alice待命],
[2019年12月22日0:00:00,2019年12月23日0:00:00,卡洛待命],
[2019年12月28日0:00:00,2019年12月29日0:00:00,斯鲁西待命],
[2019年12月29日0:00:00,2019年12月30日0:00:00,塔拉待命]
]  
**/
/**
任务3)完成工作!
**/

对于(x=0;x您要做的是更改事件创建代码以使用函数

使用此选项,您可以添加一个对象作为第四个参数,如下所示:

{
  "guests": "email1,email2,email3,groupsemail,etc",
  "sendInvites": true,
  "description": "Maybe you want to add more details? Up to you"
}
因此,请确保编辑
eventCal.createEvent(oncall、startTime、endTime);
以获得额外的参数

此外,您可能希望创建一个要自动添加的电子邮件列表,以及一个用于将姓名和电子邮件绑定在一起的键、值对


祝你好运!

你能举一个非常具体的例子说明你想做什么吗?我们可以用一个小测试数据集切实解决这个问题?我不确定你是否要求在未经他人许可的情况下编辑他人的日历?我想做的是更新谷歌工作表某些列中的单元格,并将日历邀请推送给我的人n个人,以便通知人们待命日。目前,我们只是将他们列在一张表中,并在空闲频道中呼叫他们。我注意到人们错过了这些空闲消息,因为我们在一天中有这么多频道可供控制。脚本会推送日历事件,但不会分配电子邮件,因此有人会收到标准通知tion。另外,想调用多个日历ID。感谢这里的帮助。我对编写脚本很陌生,基本上只是在研究中发现的反向工程脚本。因此,我理解您的意思,但在脚本中很难将其组合起来。我在哪里添加您的代码行?在脚本的任务3和任务4之间(第45行)然后添加第四个对象?还有,我如何设置它只运行一次特定日期?每次我运行宏时,它都会重新运行所有内容。如果您有任何帮助,我们将不胜感激。