The following script…is failing with Lion. Worked fine under Snow Leopard. Any ideas? Any ideas on how to gracefully exit if the calendar doesn't exist?
Thanks, Tim
tell application "FileMaker Pro" tell current record -- Format of date on the layout must be "1/5/03 8:00 pm" or similar set theStartDateTime to cell "ciCalStartDateTime" set theEndDateTime to cell "ciCalEndDateTime" set theSummary to cell "ciCalSummary" set alarmMinutesBefore to cell "iCalAlarmHoursBefore" * -1 * 60 -- 1 day earlier reminder (60 minutes * 24 hours) set theCalendar to cell "Bookings_PrefsX::iCalCalendarName" end tell end tell
set theStartDateTime to date theStartDateTime -- Reformat the date correctly set theEndDateTime to date theEndDateTime
set alarmMinutesBefore to alarmMinutesBefore as number
tell application "iCal" -- Find the calendar with this name set theCal to "" repeat with i from 1 to count of every calendar if title of (item i of every calendar) is theCalendar then set theCal to i end repeat
-- If the calendar does not exist then create one if theCal is "" then make new calendar with properties {writable:true} & {title:theCalendar} repeat with i from 1 to count of every calendar if title of (item i of every calendar) is theCalendar then set theCal to i end repeat end if try set new_event to make event at end of events of calendar theCal with properties {start date:theStartDateTime, end date:theEndDateTime, summary:theSummary} tell new_event make mail alarm at end of mail alarms with properties {trigger interval:alarmMinutesBefore} make display alarm at end of display alarms with properties {trigger interval:alarmMinutesBefore} end tell end try
view calendar at (theStartDateTime) activate end tell
|