Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Events.SaveCalendar

Saves changes to a calendar, or adds a new calendar to the database.

Component Version macOS Windows Linux Server iOS SDK
Events 6.2 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "Events.SaveCalendar"; EKCalendar { ; Commit } )   More

Parameters

Parameter Description Example Flags
EKCalendar The identifier or name of the calendar. $calendar
Commit Whether to commit.
Pass 1 to commit or 0 to not commit.
Default is 1.
Pass 0 to batch changes together and commit with Events.Commit later.
1 Optional

Result

Returns OK or error.

Description

Saves changes to a calendar, or adds a new calendar to the database.
This functions attempts to save the given calendar to the calendar database. It returns OK if successful and an error otherwise.

You may still need to call Events.Commit later.

Examples

Create a new calendar:

# We need a source to add the new calendar to. I prefer local, but newer macOS doesn't have it, so we use caldav for iCloud
Set Variable [ $source ; Value: MBS( "Events.SourceWithType"; "local" ) ]
If [ IsEmpty ( $source ) ]
    Set Variable [ $source ; Value: MBS( "Events.SourceWithType"; "caldav" ) ]
End If
# New calendar for events
Set Variable [ $calendar ; Value: MBS( "Events.NewCalendar"; "Event" ) ]
# configure it
Set Variable [ $r ; Value: MBS( "Events.Calendar.SetTitle"; $Calendar; "Test" ) ]
Set Variable [ $r ; Value: MBS( "Events.Calendar.SetColor"; $Calendar; "red" ) ]
Set Variable [ $r ; Value: MBS( "Events.Calendar.SetSource"; $Calendar; $Source ) ]
# save to database
Set Variable [ $r ; Value: MBS( "Events.SaveCalendar"; $calendar ;1 ) ]
# and check what ID we got for later
Set Variable [ $id ; Value: MBS( "Events.Calendar.CalendarIdentifier"; $Calendar ) ]
Show Custom Dialog [ "Saved calendar" ; $r & ¶ & $id ]

See also

Example Databases

This function checks for a license.

Created 10th March 2016, last changed 13th July 2023


Events.Reset - Events.SaveEvent