calendar 7 for Mavericks error creating open file alarm

Hi all,

Has anyone had any success creating open file alarms for Calendar version 7 for Mavericks?

The below code works with Calendar version 6 on Mountain Lion but errors in Mavericks:

set automatorScript to POSIX path of ((path to home folder as string) & "Library:Workflows:Applications:Calendar:delaySend.app")

tell application "Calendar"
	launch
	tell calendar "Automator"
		set newEvent to make new event at end with properties {description:folderName, summary:folderName, location:"Augustus Martin", start date:sendDate, allday event:false}
		tell newEvent
			make new open file alarm at end with properties {trigger interval:0, filepath:automatorScript}
		end tell
	end tell
end tell

the error Calendar reports is this:

Calendar encountered a critical error while saving to the database, and recent changes may be lost. More information may be available in the console

and the Console log reports this:

29/05/2015 08:54:25.641 Calendar[1199]: Validation error: Error Domain=CalCalendarStorePersistenceErrorDomain Code=1550 “Alerts that open files or scripts must include a file path.” UserInfo={
CalAlarmUID = “0E08C4FF-3703-449E-9480-C7549E76026D”;
CalCalendarItemUID = “D0324C30-5A6A-498F-8D0A-16D3D0D128DC”;
CalCalendarUID = “085844B1-C8A1-4A67-ACE6-95E818B7A457”;
CalManagedObjectType = CalManagedAlarm;
NSLocalizedDescription = “Alerts that open files or scripts must include a file path.”;
}

I’ve seen a few posts similar to mine on the web but no solutions, is this a bug?

Thanks,
Nik

Hi Nik,

I just made an open file alarm manually and it worked. So it must be something in your script. Did you check to see if the alarm was set right with the script?

Edited: I see. The script is not creating the alarm?

Edited: ok i see what you’re doing. You’re opening an automator app that does something. I’ll try that.

gl,
kel

Hi Nik,

I wouldn’t create an event in the Automator calendar. I’d leave that separate for the machine to use.

gl,
kel

Hi Nik,

I think I’m starting to see some anomalies with Calendar and making new events.

Edited: yes I se it. Just need to find a solution.

Edited: and btw, don’t know if this is the same hurdle, but it’s also present in Yosemite.

Edited: I think the event is there, but it is not showing up. If you close Calendar and reopen, then does the event show?

Later,
kel

Hi,

Ran this:

tell application "Calendar"
	launch
	activate
	set the_cal to first calendar whose name is "Home"
	set new_event to make new event at the_cal with properties {summary:"Hello"}
end tell

And the event didn’t show. Closed Calendar and reopened. Then the event showed.

gl,
kel

Hi Nik,

One final test you might do is create an event say one minute from the current date. See if the alarm goes off even if it is not showing in Calendar. Think I’m going to sleep soon.

gl,
kel

Hi, Nik. It does appear to be a bug. I get the same message with a variation that I wrote, and it seems that, even manually, that the entire open file alarm function may be broken. When I’m able to set it up and then go into the script editor to verify the alarm’s properties, the filepath is empty. At that point, manual readjustment results in either the alarm defaulting back to opening “Calendar” or that the choice of “Other.” stops presenting its file chooser.

Kel, Marc,

Many thanks for your feedback and apologies for my delay in responding.

Kel, I am indeed trying to create an event that launches an Automator action and the purpose of calling an Automator action is to run an Applescript on a specific date and time. Apple first removed the option to run an applescript so I had to resort to this option and now they appear to have even screwed this up!

If the Events where not such random dates and times I would have just created crontabs for them but up until 10.9 this seemed the easiest way to do it.

If anyone can think of another way of running a script at specific date and time and passing variables to it I would be very grateful.

Thanks,
Nik

For anyone who has a similar issue and needs a solution I came up with this:

Firstly I created a simple script:

on run argv
	set theName to item 1 of argv
	say theName
end run

Then I wrote myself a script to create a cron job:

set crontmp to "/Users/nikj/Desktop/crontmp.txt"
set scriptToRun to "/Users/nikj/Desktop/DoSomething.scptd"

set currCron to do shell script "crontab -l > " & quoted form of crontmp

set theVar to "Marc"

set newCronTab to "46		13	1	6	1	/usr/bin/osascript " & quoted form of scriptToRun & space & quoted form of theVar

do shell script "echo " & quoted form of newCronTab & " >> " & quoted form of crontmp

do shell script "crontab -u nikj " & quoted form of crontmp user name the "myUserName" password the "myPassword" with administrator privileges

do shell script "rm -f " & quoted form of crontmp

This gets around the problem of using Calendar to run a script on a specific date & time.

Thanks,
Nik