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

10.3: Schedule calls in iCal from Address Book Apps
I've come to love the ability to add plug-ins to AddressBook. It gives the program a lot of power and makes it easy to add new functionality in an elegant manner. The following script will place a to-do to call a person directly into your iCal calendar.

[robg update: I failed to mark this hint as 10.3 only when I posted it; apologies to those running 10.2.x who tried to get it working.]

Save the script below as a Script file in ~/Library/Address Book Plug-Ins/. Relaunch Address Book and click on the label next to a phone number. Amazing!

using terms from application "Address Book"
  on action property
    return "phone"
  end action property
   
  on action title for p with e
    set theName to (first name of p) & " " & (last name of p)
    return "Schedule call to " & 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)
    scheduleCall((id of p), theName)
  end perform action
    
end using terms from

on scheduleCall(id, name)
  tell application "iCal"
    set theItem to (make new todo at end of todo of calendar 1)
    set summary of theItem to "Call " & name
    set url of theItem to "addressbook://" & id
    activate
    show theItem
  end tell
end scheduleCall
The script will open iCal and add a new todo to the first calendar it finds. The todo will read "Call So-and-So", and the URL for the todo will link back to the address book card for that person.
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[21,307 views]  

10.3: Schedule calls in iCal from Address Book | 28 comments | Create New Account
Click here to return to the '10.3: Schedule calls in iCal from Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Schedule calls in iCal directly from AddressBook
Authored by: PancakeMan on Feb 04, '04 12:27:15PM

I get an error message - "Syntax Error: Expected "given", "into", "without" or other parameter name but found "property"." - when trying to compile this script in Script Editor 2.0.

Any ideas why?



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: Lohengrin on Feb 04, '04 12:54:02PM

This script works great, thanks!!



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: campy on Feb 04, '04 12:56:40PM

Not sure why that happened for you but it worked perfectly for me in X.3.2, i'd give it another shot. If you highlight the script from the page you can use the services menu to create the script in script editor automagically. :-)

---
-------------
Campy



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: PancakeMan on Feb 04, '04 02:04:37PM

Well, it still doesn't work, but I did learn a new handy Services menu trick! Thanks! ...
Only, selecting that service menu item fires up Classic mode to launch the OS9 Script Editor. This may be because I downloaded Script Editor 2 for OSX. Anybody know a good way to tell the system to pass the copied text to that newer editor when the menu item is selected?



[ Reply to This | # ]
Services tip
Authored by: rgray on Feb 04, '04 05:10:03PM
If you highlight the script from the page you can use the services menu to create the script in script editor automagically. Wow! didn't know.... A thing I really enjoy on this site - I always learn something new (to me.... so I'm not as sharp as some...) and often it comes from left field relative to the tip itself... Services!! da*n!! This info will make scripts a useable reality for me. thanks.........

[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: BobVB on Feb 05, '04 04:13:52PM

Replying to my own post.

The problem was there was an old OS 9 program called 'Address Book' on my hard drive and Script Editor was looking THERE for the AS dictionary.

Changed the name on the OS 9 program and it then compiled just fine.

Something so 2 apps with the same name is something to be aware of it seems.



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: miraz on Feb 04, '04 01:03:53PM

It worked nicely for me. I use the Services menu to add the script to the Script Editor. I wonder if yours could be an issue with line breaks? (Note: I'm an Applescript newbie and that's just a wild guess.)

---
Writer Trainer Web-Designer Learner



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: filmsmith on Feb 04, '04 01:27:30PM

I get the same error. I'm using 10.2.6 (sadly) and haven't been able to test it on Panther. Could that be the problem? Should this hint be made a '10.3'? Or is there a minor tweak that can help it work under 10.2?

fs



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: PancakeMan on Feb 04, '04 01:57:06PM

Maybe that _is_ the problem. I (the original error-reporter) am running Jaguar 10.2.8.



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: rluttman on Feb 04, '04 01:52:00PM

As the hint states: Save as a Script file in the Address book plug-in folder. I did it that way and it works perfectly. it is an amazing little script.



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: filmsmith on Feb 04, '04 02:04:48PM

Have you ever tried to save a script as a Script File when you can't get it to compile? Not to sound mean or terse, but you can't. THAT is the problem. If we could get it to compile, we could save it as a Script File. As it is, we're stuck saving it as a text file.

fs



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: Mara on Feb 04, '04 02:12:14PM

Same here. Using 10.3.2 and the Script works flawlessly. It even adds a link back to the Address Book entry in the "url" field in the To Do. Very nice.

BUT I did have to modify one thing: remove the backlashes before quotes. It's a silly thing, but maybe that's what makes Script Editor fail in compiling. Just a thought.



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: Mara on Feb 04, '04 02:19:24PM
PS - I meant, I don't see backslashes in the script text as it appears on the web page here, but when I copied the text from Safari and pasted it into Script Editor, for some reason the quotes appeared with backslashes before them. I didn't instantly notice that. I just did a search/replace for
\"
to
"
and it compiled.

[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: dbourbon on Feb 08, '04 07:14:02PM

I made the script and installed it in the plug-in folder and it worked great. The next time I started my Mac, it wouldn't work at all. I have written new scripts and installed them in the folder, but it doesn't have any effect. When I run the script from Script Editor (not from the Address Book) it will open iCal, but that's it. Any suggestions?



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: BobVB on Feb 04, '04 02:45:25PM

I'm with you, I get the same error as if it doesn't properly understand the 'on action property' instruction. I have no \" or any entry error that I can identify. Using 10.3.2 with script editor 2.0. Heck, the on action property won't compile even when everything else is removed.

Wonder if our installs of Applescript are faulty?



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: visigothe on Feb 04, '04 12:58:27PM

It works for me using 10.3.2 and iCal 1.5.2

Great script. I do have a few questions though. I am not an AppleScripter, but I am trying to understand a bit more of the syntax. In looking at the code, I couldn't quite figure out what "p with e" did. It is referenced several times throughout the script, but I don't see where it comes from originally. Is "p with e" defined in the dictionary of Address Book.app?

As iCal doesn't allow you to have timed "To Do"s (only date can be attached, not time), I'd love to see a modification that would create a new "Event" rather than just a To Do. Perhaps I will attempt to hack this script to do just that



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: BlackPenguin on Feb 04, '04 02:40:29PM
I'm glad people like the script; it certainly helps me a lot. You'd think Apple would put some of this functionality in... but at least there's a way to add it in later. I love plug-ins.

I probably should have mentioned that it only runs on Panther, in which the plug-in architecture was added to Address Book. I see that most have figured that out already.

About "p with e"... This is part of the Address Book Script Suite. The full command is "perform action for person with anything". This hands off both the contact and the associated property (the one whose menu was used to get to the script).

Now, if they would only add the plug-in capability to iCal...

[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: tandemrepeat on Feb 04, '04 03:04:38PM

Well this is strange - I copy it over using the Services menu, it compiles fine, save it into the Address Book scripts folder - it appears in the Address Book script menu...so far so good. When I call the script in Address Book - nothing happens. No entry into iCal..no error message...using 10.3.2 and current versions of iCal and Addressbook, Script Editor 2.0...
<b>
Strange...any insights out there?



[ Reply to This | # ]
Schedule calls in iCal directly from AddressBook
Authored by: tandemrepeat on Feb 04, '04 03:07:50PM

All right - I'm an idiot...~/Library/Addressbook Plugins and not /~LIbrary/Scripts/Address Book Scripts/...always helps to read the hint first!



[ Reply to This | # ]
URL in iCal
Authored by: locklin on Feb 04, '04 03:11:26PM

How does the url work?

I'm not getting a clickable url, just the whole url but I can't do anything with it.

Thanks in advance

---
- locklin -



[ Reply to This | # ]
URL in iCal
Authored by: tandemrepeat on Feb 04, '04 03:13:54PM

If you left-click on the portion that says "url" - a menu item saying "Go to location" pops up...



[ Reply to This | # ]
10.3: Schedule calls in iCal from Address Book
Authored by: xSmurf on Feb 05, '04 04:49:48AM

Now one needs to write a plugin that does wake up calls ;)

---
PM G4 DP 800 / 256Mb / 80Gb+40Gb /SuperDrive / SCSI: AGFA SnapScan 1236s / Jaz 1Gb / Zip 100Mb
- The only APP Smurf ;P



[ Reply to This | # ]
10.3: Schedule calls in iCal from Address Book
Authored by: alajuela on Feb 05, '04 10:50:04AM

This works great. Thanks much. I am playing with it to see if I can make the script include the actual phone number in the iCal entry rather than having to click on URL and bring up the address book again. OTOH, sometimes I change my mind and just sens someone an email, and that's easier to do from AB.



[ Reply to This | # ]
10.3: Schedule calls in iCal from Address Book
Authored by: lrivers on Feb 05, '04 04:48:24PM

That is so cool! Thanks...

I did have a problem attempting to compile it with osacompile:

22: Expected expression, etc. but found property or key form. (-2741)

Worked fine with ScriptEditor



[ Reply to This | # ]
10.3: Schedule calls in iCal from Address Book
Authored by: ola_h on May 14, '04 06:58:41AM

How can I change the script so it ads the ToDo to a named calendar?


This does not work:

set theItem to (make new todo at end of todo of calendar "Jobb")

---
/Ola



[ Reply to This | # ]
10.3: Schedule calls in iCal from Address Book
Authored by: lrivers on Aug 10, '04 01:47:41PM

See also iCal Plugins which includes:

  • Schedule a Call - this plugin script will create a new iCal ToDo item for the current person. Click on the phone label to access.
  •  
  • Create Birthday Event - this plugin script will create a new iCal Event for the current person on their birthday. Click on the Birthday label to access.
  •  
  • Create Event - this plugin script will create a new iCal Event for the current person. Click on the phone label to access.


[ Reply to This | # ]
10.3: Schedule calls in iCal from Address Book
Authored by: jenn228 on Jul 09, '07 02:00:09PM

You can also change which calendar automatically gets the todo by changing the number from 1 to whichever one works for you in the line:

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

I changed 1 to 3 to get the third calendar in my list. And this works great in 10.4!

---
jenn228



[ Reply to This | # ]
10.3: Schedule calls in iCal from Address Book
Authored by: mschmidl on Sep 12, '07 02:45:38PM
to insert the choosen phone number in the comment field of the created TODO is easy to achieve:
using terms from application "Address Book"
	on action property
		return "phone"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return "call " & 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)
		set theNumber to (value of e)
		scheduleCall((id of p), theName, theNumber)
	end perform action
	
end using terms from

on scheduleCall(id, name, phonenum)
	tell application "iCal"
		set theItem to (make new todo at end of todo of calendar 1)
		set summary of theItem to "Call " & name
		set url of theItem to "addressbook://" & id
		set description of theItem to phonenum
		activate
		show theItem
	end tell
end scheduleCall
HAVE FUN

[ Reply to This | # ]