Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Schedule iCal meetings from Address Book Apps
Based on a previous hint about adding the ability to schedule calls in iCal through the Address Book, I modified the script to let you schedule meetings the same way. This hint only works on Panther. First, highlight the script below, and click Safari -> Services -> Script Editor -> Make New AppleScript. Give the script a name, and save it in ~/Library -> Address Book Plug-Ins.

Relaunch the Address Book, and when you click on a contact's address, you should be able to schedule the meeting.

using terms from application "Address Book"
  on action property
    return "address"
  end action property
   
  on action title for p with e
    set theName to (first name of p) & " " & (last name of p)
    return "Schedule meeting with " & theName
  end action title
      
  on should enable action for p with e
    return true
  end should enable action
      
  on perform action for p with e
    set theName to (first name of p) & " " & (last name of p)
    scheduleMeeting((id of p), theName)
  end perform action
    
end using terms from

on scheduleMeeting(id, name)
  tell application "iCal"
    set theItem to (make new todo at end of todo of calendar 1)
    set summary of theItem to "Meet with " & name
    set url of theItem to "addressbook://" & id
    activate
    show theItem
  end tell
end scheduleMeeting
Now if I can just figure out how to make it allow you to choose which calendar to use...
    •    
  • Currently 3.50 / 5
  You rated: 4 / 5 (4 votes cast)
 
[9,389 views]  

Schedule iCal meetings from Address Book | 29 comments | Create New Account
Click here to return to the 'Schedule iCal meetings from Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Schedule iCal meetings from Address Book
Authored by: rhoadesco on Feb 11, '04 12:08:59PM

I did this and don't see where the script shows up at. Are you sure it goes in the Address Book Plugins vice the Scripts/Address Book folder?



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: the_argonaut on Feb 11, '04 05:48:32PM

Apparently it requires that the contact have an address. If you click on the "Home" label next to a home address, it gives you the option to schedule a meeting. I'm assuming it does the same with a work address.



[ Reply to This | # ]
Select a calendar
Authored by: paulrob on Feb 11, '04 01:45:28PM
Add the following subroutine:-

on get_cal_titles()               (*gets a list of strings of calendar titles*)
	set list_of_cals to {}
	tell application "iCal"
		repeat with aCal in calendars
			set list_of_cals to list_of_cals & (title of aCal as string)
		end repeat
	end tell
	return list_of_cals
end get_cal_titles
Replace the line in the original script that goes:-

    set theItem to (make new todo at end of todo of calendar 1)
with:-

set callist to my get_cal_titles()   (*get cal titles*)
set selectedcals to (choose from list callist) as Unicode text (*do menu with cal titles*)
set thecal to first calendar whose title is selectedcals (*identify selected cal in iCal*)
set theItem to (make new todo at end of todo of thecal)
Sorted! A simple menu will now appear to allows a calendar to be selected. Extra features can be added to the "choose from list ..." command. Check the Standard Additons dictionary for more.

[ Reply to This | # ]
Select a calendar
Authored by: paulrob on Feb 11, '04 01:48:15PM

Oops! There should be an "s" on the last "todo" in the above script, me thinks.



[ Reply to This | # ]
Select a calendar
Authored by: cjackson@class.c on Feb 11, '04 02:02:10PM

Sweet! That was a feature that I tried to implement, but I'm still learning Applescript. Next up is making a new event from the address book.



[ Reply to This | # ]
Select a calendar
Authored by: saltydog4791 on Feb 11, '04 03:32:39PM

Hey paulrob,

Thanks for adding that functionality, but I cannot get it to work. Would you mind reposting the entire revised script so I can try again? Thanks a lot.

saltydog4791



[ Reply to This | # ]
Total script
Authored by: paulrob on Feb 11, '04 04:05:03PM
Here's the complete script. Any more queries will have to wait cos this side of the Pond it's raining, it's cold - and the pubs are open.

using terms from application "Address Book"
	on action property
		return "address"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return "Schedule meeting with " & theName
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set theName to (first name of p) & " " & (last name of p)
		scheduleMeeting((id of p), theName)
	end perform action
	
end using terms from

on scheduleMeeting(id, name)
	tell application "iCal"
		set callist to my get_cal_titles() (*get cal titles*)
		set selectedcals to (choose from list callist) as Unicode text (*do menu with cal titles*)
		set thecal to first calendar whose title is selectedcals (*identify selected cal in iCal*)
		set theItem to (make new todo at end of todos of thecal)
		set summary of theItem to "Meet with " & name
		set url of theItem to "addressbook://" & id
		activate
		show theItem
	end tell
end scheduleMeeting

on get_cal_titles() (*gets a list of strings of calendar titles*)
	set list_of_cals to {}
	tell application "iCal"
		repeat with aCal in calendars
			set list_of_cals to list_of_cals & (title of aCal as string)
		end repeat
	end tell
	return list_of_cals
end get_cal_titles


[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: joeholmes on Feb 11, '04 05:15:44PM

The script is great and works perfect...except -- it creates a To Do in my iCal calendar! Anybody else see this? How do I get it to schedule a meeting?

(Anyway, thanks for the work creating this script.)

-=-Joe



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: the_argonaut on Feb 11, '04 05:53:23PM

And i thought i was going crazy... the same thing happens here. I don't know if it's s bug or feature though. :)



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: RickoKid on Feb 11, '04 07:19:47PM
This is a revision that creates an event in iCal instead of a ToDo. I also changed it to pop-up on the email field in Address Book since I have many contacts with just an email and no address.

* Change "60 * minutes" to however many minutes you want as the default duration of the meeting.

* Change "-15" to the interval in minutes between the event and the alarm: (positive for alarm that trigger after the event date or negative for alarms that trigger before) that you want as the default.

I just can't get the code to put the person from the address book into the Attendees field .. anyone got any suggestions?


using terms from application "Address Book"
	on action property
		return "email"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return "Schedule meeting with " & theName
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set theName to (first name of p) & " " & (last name of p)
		scheduleMeeting((id of p), theName)
	end perform action
end using terms from

on scheduleMeeting(id, personName)
	tell application "iCal"
		set theItem to (make new event at end of event of calendar 7)
		set summary of theItem to "Meet with " & personName
		set url of theItem to "addressbook://" & id
		set status of theItem to tentative
		set end date of theItem to (current date) + 60 * minutes as date
		make new display alarm at end of display alarms of theItem with properties {trigger interval:-15}
		(* 
		set thePerson to (make new attendee at end of attendees of theItem)
			set display name of thePerson to ("Me" as Unicode text)
			set email of thePerson to ("me@me.com" as Unicode text)
		*)
		
		activate
		show theItem
	end tell
end scheduleMeeting


[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: blalor on Feb 12, '04 07:45:23AM

That's very cool, but it makes it an event in a calendar I've *subscribed* to (ie. an uneditable calendar)! How can I choose which calendar it goes to?



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: blalor on Feb 12, '04 08:29:27AM

Nevermind; found it. Now I'm trying to get the attendees bit working. No luck so far...



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: RickoKid on Feb 12, '04 04:00:23PM
Sorry - I actually meant to put that in so it could be changed ... for anyone else who is wondering - you can change the calendar for the hint to be put in by changing the number 7 in the line:
make new event at end of event of calendar 7
As far as I can see, it numbers the calendars down from the top of the list (7 happens to be my "Meetings" calendar).

[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: blalor on Feb 12, '04 12:39:02PM
My curiosity was piqued by the "make new attendee" block that was commented out. I got it working, thanks to a link at macscripter.net (search for " Sun Nov 09, 2003 1:44 am "). The final version adds an attendee for the person you selected.

using terms from application "Address Book"
	on action property
		return "email"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return "Schedule meeting with " & theName
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set theName to (first name of p) & " " & (last name of p)
		
		scheduleMeeting(theName, (id of p), (value of e))
		
	end perform action
end using terms from

on scheduleMeeting(personName, theid, theEmail)
	
	tell application "iCal"
		set theCal to (first calendar whose title = "Home")
		
		set theItem to (make new event at end of events of theCal with properties ¬
			{summary:"Meet with " & personName,¬
 url:"addressbook://" & theid,¬
 status:tentative, start date:((current date) + 60 * minutes as date),¬
 end date:((current date) + 120 * minutes as date)} ¬
				)
		
		tell theItem
			make new display alarm at beginning of display alarms with properties ¬
				{trigger interval:-15}
			make new attendee at beginning of attendees with properties ¬
				{display name:personName, email:theEmail}
		end tell
		
		activate
		show theItem
	end tell
end scheduleMeeting

(sorry for the horrendous formatting)

[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: joeholmes on Feb 12, '04 01:42:39PM

This is fantastic -- but one more question: how can I attach the script to a field that will appear in ALL of my address book entries? That is --

Some of my address book entries have ONLY an email address. Others have a phone and work address, but no email (like my doctor, the kids' school, etc.)

What field can I specify in that very first section of the script to make sure the script will trigger from every address in my address book? I tried substituting "name" and "last name" for "email" but neither worked...

Thanks!

-=-Joe



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: blalor on Feb 12, '04 05:03:47PM
This is fantastic -- but one more question: how can I attach the script to a field that will appear in ALL of my address book entries? That is --
[...]
What field can I specify in that very first section of the script to make sure the script will trigger from every address in my address book? I tried substituting "name" and "last name" for "email" but neither worked...
First, the script requires the email address for the attendee, so I'm not sure how you'd get around that. To answer your question, however, would require someone to answer who understands that on action property bit. I don't. :-)

[ Reply to This | # ]
Brute force solution
Authored by: paulrob on Feb 13, '04 04:35:50AM

I apologise if I'm describing anything obvious to you, but if you open Applescript Editor, and select "Open Dictionary ..." from the "File" menu, and select iCal (the first iCal in the list), you can look at all the commands and classes that you can access from Applescript for iCal.

When the dictionary window comes up select "Address Book Script Suite" and then "Commands" and then click on "action property". The names appearing on the right are all you can use to action your script. You will see that this doesn't include the name! Bit annoying!

But ...

You can have more than one plugin script. Assuming that you know at least one of the following about everybody in your address book (email, address, or telephone number), you could copy the script three times, changing the return value of the action property handler to "email", "address" and "phone" respectively. For each person at least one of the above scripts would work. Obviously, if you know somebody via their AIM, you could create a fourth script and so on.

This is not the "aesthetic" solution, but at least it works better than my attempt to get the action property to return multiple values!



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: RickoKid on Feb 12, '04 04:10:17PM

Great! Who would've known that a change from "end of attendees" to "beginning of attendees" was the key!

Thanks!



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: blalor on Feb 12, '04 04:54:08PM
Apparently there's a bug with creation of attendees, as referenced in that macscripter forum. You can't do something like

set theAttendee to (make new attendee ...)

iCal throws an error (which you probably found out). Actually, I haven't tried doing the above with beginning instead of end... That's my first successful bit of AppleScript, by the way. :-)

[ Reply to This | # ]
Annoying bug (?)
Authored by: kmue on Feb 12, '04 07:46:01AM
These Adressbook Plugins are great. Thanks especially for "make new display alarm" possible. I am using it in a schedule calls plugin. But... if the Adressbook entry has only one telephone number the plugin doesn't show up. It is using action property "phone". Does anybody know a reason?

[ Reply to This | # ]
syntax error with Schedule iCal meetings from Address Book
Authored by: Bernardd on Feb 12, '04 11:52:24AM

Hi,

when I try the script I got a syntax error because of "on action property", is there something missing on my system to make scripts with on action property working?

Thanks in advance,
Bernard



[ Reply to This | # ]
Shouldn't be a problem
Authored by: paulrob on Feb 12, '04 01:55:22PM

The first script given above works on my machine - haven't tried the others.

i'm running 10.3.2, iCal v 1.5.2, and Address Book 3.1.1

if you've got these going then there shouldn't be a problem.



[ Reply to This | # ]
Shouldn't be a problem
Authored by: Bernardd on Feb 13, '04 05:08:54AM

Hi,

I use also 10.3.2 and Ical 1.5.2, but my version of Adress Book is 3.1 (v301). Do you think you've a more recent version?

Bernard



[ Reply to This | # ]
Shouldn't be a problem
Authored by: paulrob on Feb 13, '04 04:17:21PM

Seems all OK.

You should not have a problem. Are you having problems getting the script to compile? Or when you try to use the script?



[ Reply to This | # ]
Shouldn't be a problem
Authored by: Bernardd on Feb 16, '04 04:11:49AM

yes, I get the errror message when I try to compile the script.

Bernard



[ Reply to This | # ]
Shouldn't be a problem
Authored by: paulrob on Feb 16, '04 02:20:07PM

1. Check the line above the "on action ...." line. if this is in error then following line will probably fail.

2. If that's OK check the iCal app dictionary in the Script Editor. See if it shows "on action property" as a valid command. If you have problems with this then you may have a corrupt dictionary and/or application and should consider re-installing it.

3. Post the first three lines of your code if all the above is OK.



[ Reply to This | # ]
Shouldn't be a problem
Authored by: Bernardd on Feb 19, '04 09:04:31AM

Hi paulrob,

today I tried it again to compile the script, to check the three points you asked in your last message. Please don't ask me why, but today it works, I don't know if this has something to do with updating to Isync 1.4 I don't think so but who knows.

Thanks for your help
Bernard



[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: kiwioz on Mar 15, '04 08:10:44AM
Thanks for all who have posted. This is what I have done to work for me.

using terms from application "Address Book"
	on action property
		
		return "address"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return "Schedule meeting with " & theName
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set theName to (first name of p) & " " & (last name of p)
		scheduleMeeting((id of p), theName)
	end perform action
	
end using terms from

on scheduleMeeting(id, personName)
	tell application "iCal"
		
		set callist to my get_cal_titles() (*get cal titles*)
		set selectedcals to (choose from list callist) as Unicode text (*do menu with cal titles*)
		set thecal to first calendar whose title is selectedcals (*identify selected cal in iCal*)
		
		set theItem to (make new event at end of event of thecal)
		set summary of theItem to "Meet with " & personName
		set url of theItem to "addressbook://" & id
		set status of theItem to tentative
		set end date of theItem to (current date) - 250 * minutes as date
		make new display alarm at end of display alarms of theItem with    properties {trigger interval:-15}
		(* 
                set thePerson to (make new attendee at end of attendees of theItem)
                        set display name of thePerson to ("Me" as Unicode text)
                        set email of thePerson to ("me@me.com" as Unicode text)
                *)
		
		activate
		show theItem
	end tell
end scheduleMeeting

on get_cal_titles() (*gets a list of strings of calendar titles*)
	set list_of_cals to {}
	tell application "iCal"
		repeat with aCal in calendars
			set list_of_cals to list_of_cals & (title of aCal as string)
		end repeat
	end tell
	return list_of_cals
end get_cal_titles
Once again thanks to all Craig

[ Reply to This | # ]
Schedule iCal meetings from Address Book
Authored by: marook on Mar 15, '04 06:42:59PM
Hi All, Just updated this action a bit,
1: It's localizable. Edit the text properties in the top!
2: It's only possible to choose a EDITABLE calendar!
3: It's only possible to choose ONE calendar.
4: Property for Alarm default time.

Note: Example translation in Danish shown.


property titlePrefix : "Opret Begivenhed med " --"Schedule Event With "
property meetingPrefix : "Møde med " --"Meet with "
property selectCalPromt : "Opret Møde i Kalender:" -- "Create Event in Calendar:"
property alarmTrigger : -15 (*Minus is BEFORE event, Plus is AFTER the event! *)

using terms from application "Address Book"
	on action property
		return "email"
		--return "phone"
		--return "address"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return titlePrefix & theName
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set theName to (first name of p) & " " & (last name of p)
		my scheduleMeeting(theName, (id of p), (value of e))
	end perform action
	
end using terms from


on scheduleMeeting(personName, theid, theEmail)
	tell application "iCal"
		
		set callist to {}
		repeat with aCal in calendars
			if aCal is writable then set callist to callist & (title of aCal as string)
		end repeat
		activate
		set selectedcal to (choose from list callist with prompt selectCalPromt without empty selection allowed and multiple selections allowed) as Unicode text (*do menu with cal titles*)
		set thecal to first calendar whose title is selectedcal (*identify selected cal in iCal*)
		
		set theItem to (make new event at end of events of thecal with properties ¬
			{summary:meetingPrefix & personName, url:"addressbook://" & theid, status:tentative, start date:((current date) + 60 * minutes as date), end date:((current date) + 120 * minutes as date)})
		
		tell theItem
			make new display alarm at beginning of display alarms with properties {trigger interval:alarmTrigger}
			make new attendee at beginning of attendees with properties {display name:personName, email:theEmail}
		end tell
		
		show theItem
	end tell
end scheduleMeeting

Enjoy!

---
/Marook

[ Reply to This | # ]