Automators 1: Automating Calendar Events

episode

#41

Great episode lots learned and loads of workflow ideas to play with


Automators 0: Introduction
#42

Using all @Sal 's advice (thanks :smile:) here is the (hopefully) final script to bulk import events into stock MacOS Calendar app. Since all popular calendar apps use the same database, it works also with Fantastical etc.with the additional flexibility for those who use just the stock app.
You can also specify multiple alarms, as requested above by @leo. I included support for only two in my script, but if you need more, just add column(s) in the Numbers sheet and adapt the script by adding additional line(s) for third etc. alarm(s).

Bulk import of events into Calendar


tell application "Numbers"
    activate
    try
        if not (exists document 1) then error number 1000
        tell document 1
            try
                tell active sheet
                    set the selectedTable to ¬
                        (the first table whose class of selection range is range)
                end tell
            on error
                error number 1001
            end try
            tell selectedTable
                set theseRows to the rows of selection range
                repeat with i from 1 to the count of theseRows
                    copy the value of every cell of item i of theseRows to ¬
                        {eventName, eventLocation, startDate, eventDuration, endDate, eventNotes, eventAlarm1, eventAlarm2, calendarName}
                    tell application "Calendar"
                        tell calendar calendarName
                            set newEvent to make new event with properties ¬
                                {summary:eventName, start date:startDate, end date:endDate, location:eventLocation, description:eventNotes}
                            tell newEvent
                                make new display alarm at end with properties {trigger interval:-eventAlarm1}
                                make new display alarm at end with properties {trigger interval:-eventAlarm2}
                            end tell
                        end tell
                    end tell
                end repeat
            end tell
        end tell
    on error errorMessage number errorNumber
        if errorNumber is 1000 then
            set alertString to "MISSING RESOURCE"
            set errorMessage to "Please create or open a document before running this script."
        else if errorNumber is 1001 then
            set alertString to "SELECTION ERROR"
            set errorMessage to "Please select a table before running this script."
        else
            set alertString to "EXECUTION ERROR"
        end if
        display alert alertString message errorMessage buttons {"Cancel"}
        error number -128
    end try
end tell

To Use:
Copy the Numbers sheet to your Mac.
Enter/copy events (duration and alarms have to be entered in minutes).
Specify the name of the calendar you want to import into.
Select the rows you want to import.
Run the script.


#43

Check to see if it support normal importing. Should work with csv-files.


#45

We’ve been looking at those, and of course IFTTT will work on Android (and is actually more powerful on the non iCloud calendar options), we do have a section of this forum for Android though, and I hope we can find out more about the tools that you can use on Android for things like this!


#46

Great episode! Wondering if the fantastical numbers sheet will be shared?


#47

It’s in the blog post!


#48

Thanks! didn’t catch there was a blog!


#49

Question:

I have a mostly fixed schedule, but with varying start times. I’d like to be able to make a schedule for any day based on a start time and have it schedule everything out from that start time.

Ex.

Start time: Varying
Block 1: +30m from start time
Block 2: +1h
Block 3: +2h
Block 4: +2h
etc.
etc.

So far what I’ve done is modify Davids workflow for his time blocking and just insert the start and end dates manually, but it gets pretty tedious.

I’d like to be able to do it manually. I haven’t been able to figure out a way using workflow. Is there a way to do it?


#50

Have a look at this as an example:
https://workflow.is/workflows/24b35731dd8942c39bbc4001d9bbe4a3

Essentially you‚Äôre going to need a fair few ‚Äúadjust date‚ÄĚ actions - and make sure the date magic variables are set to time only :slight_smile:


#51

New Workflow - Things to Calendar

OK… so this episode inspired me to go fix a problem I was having. On the Mac, I like to plan my day with dragging Things tasks over to my calendar to block time for work. On iOS, that is not possible. Since I am now doing my planning on the train going in to work, I needed a solution.

What I did was create a Workflow share extension that takes a task from Things, and adds it to my calendar. When I share the task, it asks me when I want to start it, and defaults to a 30 min block of time. I have a chance to change that prior to saving it. It is basic, but it works.

I wish I could grab the task link, or separate the title from the Notes… but for now, this solved my problem. Sharing with all of you lovely people.

https://workflow.is/workflows/df661881e1a74faa8ab56af0401fc3c5


#53

Is there a way to make events ‚Äúall-day‚ÄĚ? I schedule the events each year for my department, and many of the events are all-day, several days, or even all-week long. Is there a way to add a column or a variable or a checkbox (something!) to the Numbers table so that it enters those events correctly?

Currently, I’ve been doing this the other way: make all the events in the calendar, and then export it as a .ics, then using Free ICS to CSV Converter convert it to CSV document, which I can then convert into a spreadsheet. Most (all?) of my colleagues are on Macs/iPhones and so being able to import a calendar into their system is ideal. But some colleagues really like to see the events as a table, just like the Numbers spreadsheet.


#54

From memory if you skip the duration it should default to an all date event.


#55

Yes, there is, through a Boolean variable. I was thinking about adding it to the table and then I decided to wait until someone asks for it :smile:. Or maybe it can be cheated by skipping duration as @RosemaryOrchard suggested. Will look into it.


#56

3 posts were split to a new topic: Editing an event with Workflow


#59

This should do it:

New version of the Numbers sheet supporting all days events

New version of the AppleScript


#60

Thank you so much for this first episode, screencasts and for sharing your workflows! The ‚ÄúParsing a list of events with Numbers‚ÄĚ will save me lots of time when adding all of my teaching classes to Fantastical. Already tried and works perfectly. Brilliant! Thank you.


#61

I’m glad you have a use for it!


#62

Thank you Jiri, @jplacek . As I try to run this, I get the same error over and over; clearly I don‚Äôt understand what I‚Äôm doing wrong. ‚ÄúCalendar got an error: Can‚Äôt make missing value into type text.‚ÄĚ

Here’s my test spreadsheet.

Any thoughts on what I’m doing wrong?


#63

Hello Eric, I tested your sheet and it seems the problem is that the field for URL/Notes cannot be empty. So if you don‚Äôt have anything specific to put there, just leave e.g. ‚Äúnote‚ÄĚ in there. It`s not very elegant solution but the fastest right now. Also I would format the alert columns as Number, although that was not the primary cause of the error you were getting. Hope this helps :smile:


#64

Love the show and this episode. My question. It seems that a lot of your bulk event scheduling was done on Mac? Is this possible on iPad? in iOS. I want to begin automating more of my calendar entries but can’t quite afford a 50 dollar calendar app on the Mac.