Google Apps脚本将事件从一个日历移动到另一个日历 [英] Google Apps Script Move Event From One Calendar To Another

查看:56
本文介绍了Google Apps脚本将事件从一个日历移动到另一个日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在在这里查看了 Mogsdad对类似问题的答案,但是这并不是我的问题所特有的.我还查看了Calendar类及其子类的文档,但没有方法(我认为应该实施;有待处理的

I looked at Mogsdad's answer to a sort-of-similar question here, but it's not incredibly specific to my problem. I've also looked at the documentation for the Calendar class and its subclasses, but there is no method (which should be implemented in my opinion; there is a pending feature request) for copying a single event from Calendar X to Calendar Y.

我想做的事情如下:

  1. 将要移动的日历事件的ID存储在某个地方.
  2. 事件Z完成后(外部条件,不是基于时间的 ),请为该函数提供日历事件ID.
  3. 该功能会将事件Z从日历X移动到日历Y.
  1. Have the ID for the calendar event to be moved stored somewhere.
  2. When Event Z is completed (external criteria, not time-based), give the function the calendar event ID.
  3. The function will move Event Z from Calendar X to Calendar Y.

我能想到的唯一方法就是马虎(下面是半伪):

The only way I could think of how to do it is sloppy (semi-pseudo below):

// y is Calendar Y, z is the ID of Event Z
function moveToNewCalendar(y, z) {

var eventToMove = getEventByID(z);

// eventDetails is an Object
var eventDetails = getAllEventDetails(eventToMove); // This is not fun!

y.createEvent(eventDetails);
eventToMove.deleteEvent();
}

function getAllEventDetails(e) {

var details = {};

details["title"] = e.getTitle();
details["startTime"] = e.getStartTime();
// ... etc

return details;

}

function createEvent(eventDetails) {
// Create event using the information pulled from eventDetails
}

此功能可通过 Google Calendar API v3-功能,而不是通过GAS.

This functionality is available through the Google Calendar API v3 - move function, but not through GAS.

我认为主要问题是复制事件的详细信息.Calendar原型中没有 createEvent(Event e)的功能.有一种更简单的方法可以使我丢失吗?

I suppose that the main problem is copying the details of the event. There is no function to createEvent(Event e) in the Calendar prototype. Is there an easier way to do this that I'm just missing?

推荐答案

新库将为您提供完整的解决方案...我很高兴成为Beta版测试人员,并且我所有的测试均成功:-)

This new library written by Romain Vialard will give you a complete solution... I had the pleasure to be a beta tester and all my tests were successful :-)

这篇关于Google Apps脚本将事件从一个日历移动到另一个日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆