Jump to content

Create an iCal event


This topic is 2946 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi all

I have a db setup that has a certain area for booking appointments. I want to be able to click a button that creates a new event in iCal, using the following fields in my database:

Date of event

Start time

Finish time

Client name (would become event name)

Payment type (would be inserted into the notes section)

Venue (venue)

Is there any possible way to do this?

Many thanks!

Link to comment
Share on other sites

  • 3 weeks later...

You will have to get your hands dirty using applescript; Here is a script I picked up from Jonathan Stark. Please note the caveats. If you don t know how to use apple script just change the cell descriptors in the "-- grab the data from Filemaker" section. Hope it helps.

(*

Create Event

Copyright © 2005 Jonathan Stark

This script automates the process of creating iCal calendar events from FileMaker records.

You may incorporate this sample code into your program(s) without

restriction. This sample code has been provided "AS IS" and the

responsibility for its operation is yours. You are not permitted to

redistribute this sample code as "Jonathan Stark sample code" after having

made changes. If you're going to redistribute the code, I would appreciate it

if you make it clear that the code was descended from Jonathan Stark's sample

code, but that you've made changes.

Have fun!

Visit www.jonathanstark.com for

more fun with FileMaker,

AppleScript, iCal, and more...

*)

-- grab the data from Filemaker

--edited by user

tell application "FileMaker Pro Advanced"

tell current record

--set theCalendarTitle to cellValue of cell "gstaff"

set theCalendarTitle to "staff leave"

set theSummary to cellValue of cell "booked leave::icalSummary"

--set theDescription to cellValue of cell "Description"

set theDescription to ""

set theStartDate to cellValue of cell "booked leave::Start"

--set theStartTime to cellValue of cell "Start Time"

set theStartTime to "0"

set theEndDate to (cellValue of cell "booked leave::icalfinish")

--set theEndTime to cellValue of cell "End Time"

set theEndTime to "0"

--set theAllDay to cellValue of cell "All Day"

set theAllDay to "1"

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

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

Link to comment
Share on other sites

  • 1 month later...

Love what you can do with Applescript. This video from PauseOnError in NYC is worth checking out if you're interested in seeing more of what AS can do with FMP:

But if you have FileMaker Server and don't want to use AppleScript, you can use Zulu to link your FileMaker database to iCal (this also passes edits made in iCal back to FileMaker). More here: http://www.seedcode.com/zulu

Link to comment
Share on other sites

I Used to use AppleScript to do this, now I don't have to spend the time playing around and thanks to Zulu I don't have to. I strongly recommend you download a demo copy and see how easy it is. Cross platform too!

Link to comment
Share on other sites

  • 1 year later...
  • Newbies

This is great!

 

Ive been using it for quite some time now but finally decided to fix an old issue.

That is: duplicates being created in iCal as I update my filemaker database and then export the changed post to iCal.

 

I need to save the events UID from ical to my filemakerpost and then as I post the update I would like to first delete the stored iCal record and after that create a new one and save its UID.

 

But I fail already on step 1, retrieveing the UID into a filemakerfield.

I added two lines to the script:

 

-- set the event properties
    tell theEvent
        set start date to theStartDate
        set end date to theEndDate
        set summary to theSummary
        set description to theDescription
        set location to thelocation
        return uid of theEvent
        set theUID to the uid of theEvent

 

And then i thought inserting the following new ending would fix things, but no....

 

 

tell application "FileMaker Pro Advanced"
    activate
    tell database "MoPaCalendar"
        tell table "SampleEvents"
            set field "iCal_Event_id" to "theUID"
        end tell
    end tell
end tell
 

Cant understand why it wont work.

Grateful for any help!

Link to comment
Share on other sites

  • Newbies

If I end my script like this I get a UID into my filemaker solution. But first after a protest that theUID isnt defined and then a message saying some fault number.

But then the UID is actually inserted after all. BUT! its inserted into each and every post in the database, not just the active one.

 

 

 
    -- set the event properties
    tell theEvent
        set start date to theStartDate
        set end date to theEndDate
        set summary to theSummary
        set description to theDescription
        set location to thelocation
        set theUID to the uid of theEvent
        if theAllDay = "1" then
            set allday event to true
        end if
    end tell
    tell application "FileMaker Pro Advanced"
        activate
        tell database "MoPaCalendar"
            tell table "SampleEvents"
                set field "iCal_Event_id" to theUID
            end tell
        end tell
        
        tell application "Calendar"
            activate
            show theEvent
        end tell
    end tell
end tell
 

---

 

Feels like Im getting closer after all but theres too much here that I dont really understand.

Link to comment
Share on other sites

  • Newbies

Keep trying but with less success.

 

Heres my latest copy with comments:

 

Before this script is run Id like another script to run which deletes a certain ical
event if its been previously published and its UID has been saved in the current filemaker record.

But to do that I first need to get that darn UID in there...


-- grab the data from Filemaker
tell application "FileMaker Pro Advanced"
    tell current record
        set theCalendarTitle to cellValue of cell "iCal_calendarname"
        set theSummary to cellValue of cell "Summary"
        set theDescription to cellValue of cell "iCal_body"
        set theStartDate to cellValue of cell "DateStart"
        set theStartTime to cellValue of cell "TimeStart"
        set theEndDate to cellValue of cell "DateEnd"
        set theEndTime to cellValue of cell "TimeEnd"
        set theAllDay to cellValue of cell "AllDay"
        set thelocation to cellValue of cell "Resource"
    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 "Calendar"
    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
        set location to thelocation
        return uid of theEvent
        set theUID to the uid of theEvent
        if theAllDay = "1" then
            set allday event to true
        end if
        
        show theEvent
        
    end tell
end tell

-- Cant understand why these last lines below do nothing. If ran in scripteditor the result is a UID from ical but its NOT inserted into my filemakerfile.

tell application "FileMaker Pro Advanced"
    tell current record
        set cell "iCal_Event_id" of current record to theUID
    end tell
end tell

Link to comment
Share on other sites

  • 1 year later...

Ive been playing around with the above script as this is something I'm trying to do. After many hours I have found out it seems to be the line "return uid of theEvent". With this line removed, FM updates.

 

Not sure why, possibly because the 'return' ends the script, thats my guess.

Link to comment
Share on other sites

This topic is 2946 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.