« MBS FileMaker Advent … | Home | MBS FileMaker Plugin,… »

MBS FileMaker Advent calendar - Door 16 - Add Entries In Apple Calendar

candy cane Monkeybread Monkey as an elf candy cane
Day 16 - Add Entries In Apple Calendar

Our monkey has lots of appointments and uses the Apple Calendar app to keep track of them. Now it would be nice if our monkey could also enter appointments directly from FileMaker into this calendar and we would like to implement this today. The functions from the Calendar section are available for this purpose.

Since our layout is getting pretty full and we don't need to see the information from the last created appointment on the layout all the time, we use a button with a popover and position our fields on this popover. As the fields do not belong to a specific data record, we create these fields as global fields in the Data table. We need the following fields:

Appointment_Title Text
Appointment_Start Timestamp
Appointment_End Timestamp
Appointment_All Day Text
Appointment_URL Text
Appointment_Location Text
Appointment_Notes Text

We can fill these fields with information later when we create an appointment. The appointment should then be transferred to the calendar app by clicking on a button. Behind this button is the script that I would now like to introduce to you.

As we have already seen several times, the plugin often works with references in the workspace. This is also the case here. We first create a new calendar entry with Calendar.NewEvent. We can address this entry with the reference that the function returns. Now we can already set the individual information of the event. First of all, this is the title of the event. We set this by specifying the reference and the title using the Calendar.Item.SetTitle function. Now we can set the start and end times with Calendar.Item.SetStartDate and Calendar.Item.SetEndDate. Here we pass the respective timestamp in addition to the reference. We specify whether an appointment is an all-day appointment with Calendar.Item.SetAllDay. If we pass a 1 in the parameters here, the appointment is an all-day appointment. If we enter a 0, it is created as an appointment with a time frame that is described in Start and End Date. If there is an Internet page with further information for this appointment, e.g. for an event, it is a good idea to add this to the appointment with Calendar.Item.SetURL. We can also use Calendar.Item.SetLocation to specify the location where the event is to take place. If the information in the title of the calendar entry is not sufficient or if you have further information about an appointment, you can enter this as a note with Calendar.Item.SetNotes.

In the calendar app, we have the option of having several calendars. For example, public holidays are displayed in a different color than my own appointments or birthdays. This helps to keep an overview. Before we can make an entry in the calendar, we have to decide in which calendar the appointment should be entered. We then set the name of this calendar with Calendar.Item.SetCalendar.

The Calendar.SaveEvent function then saves our calendar entry in the calendar.

Our script is now complete and looks like this:

Set Variable [ $Cal ; Value: MBS("Calendar.NewEvent") ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetTitle"; $Cal; Data::Appointment_Title) ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetStartDate"; $Cal; Data::Appointment_Start) ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetEndDate"; $Cal; Data::Appointment_End) ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetAllDay"; $Cal; Data::Appointment_All Day) ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetURL"; $Cal; Data::Appointment_URL) ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetLocation"; $Cal; Data::Appointment_Location) ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetNotes"; $Cal; Data::Appointment_Notes) ]
Set Variable [ $r ; Value: MBS("Calendar.Item.SetCalendar"; $Cal; "Test") ]
Set Variable [ $r ; Value: MBS("Calendar.SaveEvent"; $Cal) ]

That's it for today and I hope to see you again tomorrow.


Monkeybread Software Logo with Monkey with Santa hat
15 👈 16 of 24 👉 17
Claris FileMaker Plugin
16 12 24 - 07:45