任何人都可以帮助我将以下脚本用于日历工作。它适用于所有单个日历活动。但它有一个反复出现的事件,它只会改变颜色并且不会更新标题。
我希望以下内容发生
用户创建活动并邀请共享日历。然后,这将使用用户名更新事件标题。
偶数标题只需要在共享日历上更新
function Update_Business() {
var mycal = "xxxxxxxxxxxxxxxxxx@group.calendar.google.com";
var mainCal = "xxxxxxxxxxx@xxxxxxxxxx.com";
var First = new Date();
First.setHours(0, 0, 0, 0);
var Last = new Date();
Last.setDate(First.getDate() + 30);
var cal = CalendarApp.getCalendarById(mycal);
var events = cal.getEvents(First, Last, { search: '-At' });
for (var i = 0; i < events.length; i++) {
var ev = events[i];
Logger.log(ev.getTitle())
var title = ev.getEventSeries().getTitle();
var eventId = events[i]
var title = events[i].getEventSeries().getTitle();
var creator = events[i].getEventSeries().getCreators();
var contact = ContactsApp.getContact(creator);
var CreatorName = contact.getNickname()
events[i].getEventSeries().setTitle(CreatorName + " at " + title).setColor(11);
}
}
答案 0 :(得分:1)
我还没有测试过这段代码,但我认为这可能有所帮助。
function Update_Business()
{
var mycal = "xxxxxxxxxxxxxxxxxx@group.calendar.google.com";
var mainCal = "xxxxxxxxxxx@xxxxxxxxxx.com";
var min=60 * 1000;
var hr=60 * min;
var day=24 * hr;
var wk=7 * day;
var First = new Date(new Date().setHours(0,0,0));
var Last = new Date(start.valueOf() + (30 * day));
var cal = CalendarApp.getCalendarById(mycal);
var events = cal.getEvents(First, Last, { search: '-At' });
for (var i = 0; i < events.length; i++)
{
var ev = events[i];
Logger.log(ev.getTitle())
var title,eventID,creator,contact,creatorname;
if(ev.isRecurringEvent())
{
title = ev.getEventSeries().getTitle();
eventID=ev.getEventSeries().getId();
creator=ev.getEventSeries().getCreators();
contact = ContactsApp.getContact(creator);
creatorname = contact.getNickname();
ev.getEventSeries().setTitle(creatorname + " at " + title).setColor(11);
}
else
{
title=ev.getTitle();
eventID=ev.getId();
creator=ev.getCreators();
contact = ContactsApp.getContact(creator);
creatorname = contact.getNickname();
ev.setTitle(creatorname + " at " + title).setColor(11);
}
}
}