Modify Script to Include Event Organiser and Attendees

Hi

I would like to add the event organiser and event attendees to this script.

Can anyone help?

// Create meeting minutes
var calendars = [“Kalender”, “Ralf”];
var today = new Date();
var yesterday = new Date(today.getTime() - 10006060*24);
var print_event = (e) => ${strftime(e.startDate, "%R")} - ${e.title};
var events = calendars
.reduce((e, c) => e.concat(Calendar.find(c).events(yesterday, today)), [])
.sort((a, b) => a.startDate - b.startDate)
.reverse()
.filter(e => !e.isAllDay)
var event_template =
MustacheTemplate.createWithTemplate(Draft.find(“74554985-BE84–4C11-A7AE-07883A9A5C19”).content);
var p = Prompt.create();
p.title = “Meeting Note”;
p.message = “Choose an event. the current draft will be appended to the template and tagged meeting.”;
if (events) {
p.addSelect(“event”, “Events”, events.map(e => print_event(e)), [], false);
p.addButton(“Create Meeting Note”);
prompt = p.show();
if (p.buttonPressed == “Create Meeting Note”) {
// process the event
event = events.find(e => print_event(e) == p.fieldValues[“event”])

var data = {
“title”: event.title,
“startDate”: strftime(event.startDate, “%Y-%m-%d-%H%M”),
“notes”: event.notes,
“content”: increaseMDLevel(draft)
};
result = event_template.render(data);
draft.addTag(“meeting”);
draft.content = result;
draft.update();
}
}

The forum will mess with the code if you don’t put it between triple back ticks to make it a code block.

Here is a reformatted version of your code.

//Create meeting minutes
var calendars = ["Kalender", "Ralf"];
var today = new Date();
var yesterday = new Date(today.getTime() - 10006060 * 24);
var print_event = (e) => $
{
	strftime(e.startDate, "%R")
} - $
{
	e.title
};
var events = calendars
	.reduce((e, c) => e.concat(Calendar.find(c).events(yesterday, today)), [])
	.sort((a, b) => a.startDate - b.startDate)
	.reverse()
	.filter(e => !e.isAllDay)
var event_template =
	MustacheTemplate.createWithTemplate(Draft.find("74554985-BE84–4C11-A7AE-07883A9A5C19").content);
var p = Prompt.create();
p.title = "Meeting Note";
p.message = "Choose an event. the current draft will be appended to the template and tagged meeting.";
if (events)
{
	p.addSelect("event", "Events", events.map(e => print_event(e)), [], false);
	p.addButton("Create Meeting Note");
	prompt = p.show();
	if (p.buttonPressed == "Create Meeting Note")
	{
		// process the event
		event = events.find(e => print_event(e) == p.fieldValues["event"])

		var data = {
			"title": event.title,
			"startDate": strftime(event.startDate, "%Y-%m-%d-%H%M"),
			"notes": event.notes,
			"content": increaseMDLevel(draft)
		};
		result = event_template.render(data);
		draft.addTag("meeting");
		draft.content = result;
		draft.update();
	}
}

The data variable is where the attendee information would get added in, but I don’t see an organiser attribute on the event object. I don’t know how you would get that without going out to something else. Maybe AppleScript might allow it if this was to be run on the Mac only?

However, adding the attendees and any other data to the data variable is only half the battle. The script references another draft which is presumably a mustache template. Can you provide details for that too?

Not possible. Apple’s APIs only support reading the values for organizer and attendees, not setting them.

I believe the OP is outputting the event details into a draft for meeting notes, so it would just be reading the data.

Oh, got it…answering too quickly. Yes, those properties are available and documented in the scripting reference.