Get Calendar Lib to also set meeting URL

Calendar Lib can create and edit events but seems restricted in that it can only add or amend Event Titles, timings, locations, attendees etc - is it possible to amend to also modify events to add to the URL field of an event?

Use case: I’ve been using CalendarLib for ages but have now moved to use MeetingBar, which displays all my upcoming meetings today, and searches the URL field of upcoming events to variously create links to open zoom, Teams, FaceTime etc as the meeting requires.

I have a calendar booking system on my website which creates events when selected by my clients, but it doesn’t include the option to populate the URL field of an event. So, I encode the URL into the meeting location field.

I want to run a script on my mac which is triggered when the calendar is updated, finds all the events which have been added for today, and searches the location field, pulls out the details and adds it into the URL field.

I can do every part of the putting the URL together, and can find the relevant events to edit in CalendarLib but I can’t use CalendarLib to modify the event to populate the URL field.

So a result, I have to use native applescripting of Calendar to create a event set based on using the less efficient and more CU intensive method of finding every event in a certain calendar which has a start date of today, and amending them this way. I’d love to be able to use CalendarLib to just make the modification to each event which would be lighting quick.

Events have a URL property, so you should be able to do it with a couple of lines of ASObjC. You’d need to create an NSURL, then pass it to a call of setURL: on the event.

OK thanks Shane.

I’m not able to write those lines of code due to lack of expertise sadly - I wondered if anyone here had some example code I could bastardise?

Try this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use framework "EventKit"
use script "CalendarLib EC" version "1.1.5" 
use scripting additions

-- your code to get the event goes here, and stores it in theEvent
-- assume urlString contains the URL properly escaped

set theURL to current application's NSURL's URLWithString:urlString

Hi Shane - I did this:

set theStore to fetch store
set theCal to fetch calendar "Call/Meet" cal type cal cloud event store theStore
set theEvents to fetch events starting date (current date) ending date (current date) + 2 * days searching cals theCal event store theStore
repeat with anevent in theEvents
	set theinfo to (event info for event anevent)
	set theloc to event_location of theinfo
	set thetext to event_description of theinfo
	my gettheurl(theloc, thetext)
	set theURL to do shell script "php -r 'echo urlencode(\"" & theURL & "\");'"
	set theURL to (current application's NSURL's URLWithString:urlString)
end repeat

(the subroutine ‘gettheurl’ takes the text from the event details and extracts the URL from either the location or the event description and send it back as a URL)

It threw this error:

error "The variable urlString is not defined." number -2753 from "urlString"

I’m not sure what you’re doing there, but try this:

	set urlString  to my gettheurl(theloc, thetext)
	set theURL to (current application's NSURL's URLWithString:urlString)