harges Posted September 24, 2005 Posted September 24, 2005 I'm writing a script to take data from a FileMaker 7 file and create iCal events with it. The FM data is a series or records, each containing three fields, like so: AAA-111 09/23/05 Description of event I can figure out how to use FM to find and sort the records I want and then export them as a tab-delimited text file. And then I can read that text file in Apple Script, coerce some of the data and then create iCal events. However, I'd like to do this without the step of having to create a text file and then open it for access in Apple Script. Does anyone know if I can skip this step by having FileMaker export the data to the clipboard? My plan is for this script to be run from Filemaker. It will likely be a FM script that calls the AppleScript after exporting its data. Any ideas? Thanks.
Fenton Posted September 24, 2005 Posted September 24, 2005 (edited) I following AppleScript will create a new event in iCal, from FileMaker (though I haven't tested it for while). You can remove any parts you don't need. The Status is a bit tricky to set; the status are constant values that cannot be set with text values; that's why it has its own routine. Date in AppleScript is a TimeStamp in FileMaker, when going out (more difficult going from AppleScript to FileMaker). Change fields, calendar name, etc., to your info. Copy/paste into a Perform AppleScript script step. Be on the layout/record with the data when you run it. property calTitle "Home" global theCalendar global theEvent global theStatus global theAttendee --tell application "FileMaker Developer" tell current record of document "FM_to_iCal.fp7" set dateStartTxt to cell "_cTimeStampStart" set dateEndTxt to cell "_cTimeStampEnd" --The above must be TimeStamp fields; construct from Date & Time fields set theSummary to cell "EventName" set theStatus to cell "Status" set theLocation to cell "Location" set theAttendee to cell "Client" set theEmail to cell "Email" set theCalendar to cell "CalendarName" end tell --end tell set DateStart to date dateStartTxt set DateEnd to date dateEndTxt tell application "iCal" set theCalendar to item 1 of (every calendar whose title is calTitle) tell theCalendar set theEvent to make new event at end of events tell theEvent set start date to DateStart set end date to DateEnd set summary to theSummary set location to theLocation set allday event to false my set_status(theStatus) if theAttendee is not "" then try make new attendee at beginning of attendees with properties {display name:theAttendee, email:theEmail} end try end if end tell end tell end tell on set_status(theStatus) tell application "iCal" tell theCalendar tell theEvent if theStatus is "None" then set status to none else if theStatus is "Tentative" then set status to tentative else if theStatus is "Confirmed" then set status to confirmed else if theStatus is "Cancelled" then set status to cancelled end if end if end if end if end tell end tell end tell end set_status Edited September 24, 2005 by Guest signature was too close to code
harges Posted September 24, 2005 Author Posted September 24, 2005 Thanks. So basically, I have to iterate through records in a found set and either: a. build a list of Apple Script records that I later use to create events in iCal b. iterate through one FileMaker record at a time and create an iCal event with the data pulled from that record I was hoping to somehow access a whole set of selected fields in the records of a found set (much like the file that the Export function creates) and use that data to create events in iCal with something like the following: global record_tester set record_tester to {{date:"09/13/05", task:"JAN001 Design Direction in FedEx"}, {date:"09/13/05", task:"BHS001 Internal Review"}, {date:"09/14/05", task:"SAF006 D1"}} tell application "iCal" set home_cal to (first calendar whose title is "TESTER") repeat with i from 1 to count of records in record_tester --get date from list set date_string to date of record i of record_tester --coerce date to AppleScrip/iCal type date set date_string to date date_string as date --get event from list set task_holder to task of record i of record_tester as text --put in calendar make new event at end of events of home_cal with properties {summary:task_holder, start date:(date_string + (1 * hours)), end date:(date_string + (2 * hours)), allday event:true} end repeat end tell
Fenton Posted September 24, 2005 Posted September 24, 2005 You could do it either way. You could do it one at a time, as my script did. Or you could build a list of AppleScript "records" (a record being a list of name: "value" pairs, such as you typed above). Personally I'm more of a FileMaker developer than an AppleScript developer, so I take the easy way out, and use a FileMaker Loop, creating one event at a time. Actually I was doing synchronization, which is more difficult. So I wasn't much concerned with raw speed. There are other even faster ways and tools I imagine. Such as Script DB (which is a inexpensive Script Addition to treat AppleScript lists much like a database would, http://www.applescriptdb.com/ But I haven't really got into that. BTW, I found a bug in the iCal AppleScript implementation which put me off. You cannot set the note of a ToDo. I don't know if it's fixed in Tiger (or if iCal is different, I have 1.5.5). Another possibility is to Export from FileMaker using XML/xsl, to create a .ics file, which is a VCALENDAR format (a type of vCard I guess). It is probably the fastest method for raw speed of many records. But it's "butt ugly", as my daughter would say. You may however be able to find examples that work somewhere. Perhaps Cleveland Consulting has one? I know they do something like this.
harges Posted September 27, 2005 Author Posted September 27, 2005 Thanks for the help. I found a wierdo bug in iCal too. If you create an all day event in iCal using applescript and don't specify a time (any wahy would you--it's an all day event), then something odd happens and iCal won't display the event record properly in the calendar views. You can see the event's information in the sliding panel but it just appears as an outline instead of a solid pill shaped graphic at the top of a day in a calendar view. Very odd.
Recommended Posts
This topic is 6999 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now