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.

I’ve searched for the “organizer” property but have not found it. Is it supposed to be part of the attendees array? I’ve tested with a few Microsoft Exchange events and only attendees, not the organizer, are contained in that array.

Sorry to revive an old post; I was searching for something else when I saw the title.

I do something similar to get my meeting notes into Drafts, but I use shortcuts to pull the calendar data and build the draft.