问题描述
我在在这里查看了 Mogsdad对类似问题的答案,但是这并不是我的问题所特有的.我还查看了Calendar类及其子类的文档,但没有方法(我认为应该实施;有待处理的功能请求)以复制单个事件从日历X到日历Y.
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.
我想做的事情如下:
- 将要移动的日历事件的ID存储在某个地方.
- 事件Z完成后(外部条件,不是基于时间的 ),请为该函数提供日历事件ID.
- 该功能会将事件Z从日历X移动到日历Y.
- Have the ID for the calendar event to be moved stored somewhere.
- When Event Z is completed (external criteria, not time-based), give the function the calendar event ID.
- 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脚本将事件从一个日历移动到另一个日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!