AndrewJudd

Adding a birthday to Ica with Applescript

Discussion created by AndrewJudd on Jul 29, 2016

hi all, I am working on a button to automatically add a contact's birthday to iCal. It works up to creating the date but I'm not sure how to add a repeat every year step. Quite important, otherwise all it does is create one date in your calendar, which might be in the 1980s for example.

 

thanks for any ideas!

 

 

 

 

 

-- grab the data from Filemaker

tell application "FileMaker Pro"

    tell current record

        set theCalendarTitle to cellValue of cell "Birthdays"

set theSummary to cellValue of cell "FULL NAME"

set theDescription to cellValue of cell "FULL NAME"

set theStartDate to cellValue of cell "Date of Birth"

set theEndDate to cellValue of cell "Date of Birth"

set theAllDay to cellValue of cell "All Day for Birthday Calendar"

end tell

end tell

 

set theStartDateAsText to theStartDate

set theEndDateAsText to theEndDate

 

-- 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

  

    -- set the event properties

    tell theEvent

        set start date to theStartDate

        set end date to theEndDate

set summary to theSummary

set description to theDescription

if theAllDay = "1" then

            set allday event to true

        end if

 

 

    end tell

    show theEvent

end tell

Outcomes