iCal and apple script

Discussion in 'Mac Apps and Mac App Store' started by Steiner, Oct 28, 2006.

  1. Steiner macrumors newbie

    Joined:
    Oct 24, 2006
    Location:
    South of England
    #1
    I am using Filemaker 8.5 and would like to export field content to iCal.

    I have all the fields working except for the attendees (1 result string and not Multiple people).

    Does anyone know why I can not set the attendees in iCal through the following apple script?

    -- grab the data from Filemaker
    tell application "FileMaker Pro"
    tell current record
    set theCalendarTitle to cellValue of cell "iCal Calender"
    set theSummary to cellValue of cell "iCal Summary"
    set theDescription to cellValue of cell "iCal Description"
    set theStartDate to cellValue of cell "iCal Start Date"
    set theStartTime to cellValue of cell "iCal Start Time"
    set theEndDate to cellValue of cell "iCal End Date"
    set theEndTime to cellValue of cell "iCal End Time"
    set theLocation to cellValue of cell "iCal Location"
    set theAttendees to cellValue of cell "Full Name"
    end tell
    end tell

    set theStartDateAsText to theStartDate & " " & theStartTime as text
    set theEndDateAsText to theEndDate & " " & theEndTime as text

    -- convert text to dates
    set theStartDate to date theStartDateAsText
    set theEndDate to date theEndDateAsText

    -- create the event in iCal
    tell application "iCal"
    activate

    -- make new calendar if need be
    set allCalendarTitles to the title of every calendar
    if allCalendarTitles contains theCalendarTitle then
    set theCalendarNumber to (first calendar whose title is theCalendarTitle)
    else
    set theCalendarNumber to (make calendar at end of calendars with properties {title:theCalendarTitle})
    end if


    -- make event
    set theEvent to (make event at end of events of theCalendarNumber with properties {start date:theStartDate, end date:theEndDate, summary:theSummary, description:theDescription, location:theLocation, attendees:theAttendees})
    show theEvent

    end tell


    :confused: :confused:
     
  2. HexMonkey Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #2
    Those other fields are mostly strings or dates, but for attendees iCal uses a list of "attendee" objects, so you need to directly create one for each attendee. For example:

    Code:
    set theEvent to (make event at end of events of theCalendarNumber with properties {start date:theStartDate, end date:theEndDate, summary:theSummary, description:theDescription, location:theLocation})
    tell theEvent to make new attendee at beginning of attendees with properties {display name:theAttendees}
    If theAttendees stores a list of names, you'd need to do some string manipulation first and then create multiple attendees.

    For reference, here's the properties in the attendee class, if you want to add some details:

    display name (Unicode text, r/o) : The first and last name of the attendee.
    email (Unicode text, r/o) : e-mail of the attendee.
    participation status (unknown/accepted/declined/undecided) : The invitation status for the attendee.
     
  3. Demon Hunter macrumors 68020

    Joined:
    Mar 30, 2004

Share This Page