Drafts Scripting Reference

Event

Event object represent individual calendar events.

Instance Properties

Instance Functions

Examples

var calendar = Calendar.findOrCreate("Activities");
var event = calendar.createEvent();
event.title = "Dinner Party";
event.notes = "Bring side dish.";
event.startDate = Date.parse("7pm next friday");
event.endDate = Date.parse("10pm next friday");
event.isAllDay = false;
if (!event.update()) {
  console.log(event.lastError);
}
var cal = Calendar.findOrCreate("Test");
var event = cal.createEvent();

event.title = "My Event";
event.startDate = (5).days().fromNow();
event.endDate = (5).days().fromNow();
event.isAllDay = true;

// display event to user for modifications
if (event.edit()) {
	console.log("Event created");
}
else {
	context.cancel();
}