Hey guys!
I am very novice when it comes to programming but I can usually figure things out given enough time, but I have been struggling with a problem for a while now and could use some help.
I am trying to write a script that will take my clipboard, which contains a few lines of event titles that i want to create an event. So far I’m able to get the clipboard content, put it into an array line by line, but when trying to create an event is where I am having issues.
Originally when i tried to run it i received the error:
“Error on line 11:16: No calendar has been set.”
So I tried to set the calendar but I cannot figure it out. Based on some stackoverflow posts and looking at the documentation for scriptable I was heading down the path of using addEvent.calendar but you can see its wrong and not working.
I’m hoping someone can help me fix the code so that it creates an event in the calendar that I choose. Thanks.
let clipboardContent = Pasteboard.paste();
let addEvent = new CalendarEvent();
calendarEvents = clipboardContent.split("\n");
console.log(calendarEvents[0]);
for (i = 0; i < calendarEvents.length; i++) {
addEvent.title = calendarEvents[i]
addEvent.calendar = "work"
addEvent.save()
}