Three Questions on Address Book code scriplet

I found this co-authored years ago by Scott Paulis and Bruce Phillips:
tell application "Address Book"
set thePeople to selection
display dialog "What tag would you like to append?" buttons {"Cancel", "Apply"} default button "Apply" default answer "[tag]"
set dialogInfo to result
set selectedButton to button returned of dialogInfo
set tagString to text returned of dialogInfo
if selectedButton is "Apply" then
repeat with aPerson in thePeople
set currentNote to the note of aPerson
if currentNote is missing value then set currentNote to ""
set newNote to currentNote & " "
-- insert a newline here! Stringchar(13)?
set note of aPerson to newNote & tagString
end repeat
end if
end tell
Question 1: what is the syntax to accomplish the newline insertion noted above?
Question 2: what magic is necessary to mark the record as "changed"? I say this because contact records changed with this code are not being overwritten onto my iPhone unless I manually make a change -- so clearly the A.B. UI does something "more" to close a record.
Question 3: suggestions on how to add a third option {"Remove"}?
Thanks much and Happy Holidays,
Paul

I really don't see any difference between a new line of text and a tag. So may I suggest a new version of the script:
--BEGINNING OF SCRIPT
tell application "Address Book"
set thePeople to selection
display dialog "What text would you like to remove or append?" buttons {"Cancel", "Remove", "Append"} default button "Append" default answer "The text"
set dialogInfo to result
set selectedButton to button returned of dialogInfo
set textString to text returned of dialogInfo
if selectedButton is "Append" then
repeat with aPerson in thePeople
set currentNote to the note of aPerson
if currentNote is missing value then set currentNote to ""
if currentNote is not "" then set currentNote to currentNote & space -- or 'return'
set newNote to currentNote & textString
set note of aPerson to newNote
end repeat
else if selectedButton is "Remove" then
repeat with aPerson in thePeople
set currentNote to the note of aPerson
if not (currentNote is missing value or currentNote is "") then
if currentNote is in {space, return} then
set newNote to ""
else
if last character of currentNote is in {space, return} then
set currentNote to text 1 through -2 of currentNote
end if
if currentNote ends with textString then
if currentNote is textString then
set newNote to ""
else
set L to length of textString
set newNote to text 1 through -(L + 1) of currentNote
end if
end if
end if
end if
set note of aPerson to newNote
end repeat
end if
save
end tell
--END OF SCRIPT

Similar Messages

  • Basic question about address book / gmail sync

    Does the itunes address book / gmail sync feature only sync between those two contact lists, or if I enable gmail sync, will all of my gmail contacts be put on my iphone?
    I have only one folder of about 200 contacts in address book synced to my iphone. But address book and gmail have about 1,000 contacts each. I don't want all of those contacts on my phone.
    Thanks.

    Found an answer to my main question regarding the separate address books, looks like Lion Server is capable of doing personal address books for each user: http://www.wegotserved.com/2011/10/06/os-lion-server-home-server-part-11-shared- address-book/

  • Easy newbie question re; Address Book

    I am trying to add a keyword in the Note field of each person to whom I want to send a Xmas card. I hit "edit" and then I cannot use my mouse to go immediately to the "note" field. It stays in the "first name" field unless I use the tab key to go down one-by-one.
    How to quickly access the "note" field?
    Thanks in advance for any help with this! (I bet this one has a "duh" type answer.)
    edited: I was clicking on the word "note" instead of inside the empty area. Sorry for the stupidity of the question. Duh!
    Message was edited by: MarieBoyer

    Hi Marie,
    why not create a group in Address Book (hit the '+' symbol in the bottom left hand corner)? Call it 'Christmas cards' and then drag the applicable contacts into this list. Don't worry as they not duplicated but just referenced from the total list of contacts. You could make 'sent' and 'received' lists if you wanted.
    Seasons greetings!
    Steffan

  • Question on Address Book

    Is it possible to take the Name and Address directly from the Address Book and print in on an envelope? I understand mailing labels but would prefer the direct print method if possible.
    Thanks in Advance
    John

    A couple of things; your directions to the envelope was great . However, my Epson CX6000 doesn't seem to want to print the envelope. I get a message that the paper is out or not loaded correctly. I guess I'll have to talk to Epson about that.
    The other thing is that the name and the address are not together as you would normally type the name and address. In the Preview the Name is off to the left and the addriss is on the right side of the page. When I print it on an 8x11 page it looks like this:
    Name Address
    City, State, Zip
    is there a way to change this?
    John

  • Address Book / PocketMac / BlackBerry syncing issue

    Hi folks:
    Wonder if anyone's expertise could help illuminate what's going on with my setup. I had a BlackBerry synced with Outlook on my old PC, which I recently replaced with a new MacBook. I was able to use PocketMac to easily sync my BlackBerry with Address Book and Mail on the new MacBook- or so I thought.
    Turns out there are some fields included with contacts in my BlackBerry that do not appear with the corresponding contact entry in Address Book. For instance, a given contact will have four or five phone numbers listed on the BlackBerry, with only two or three on the Address Book. I thought that by syncing the two devices I would get an exact match for the data on each one. Was I wrong?
    Any ideas? Any setting I can change, or workarounds I can use to make the information complete on both devices?
    Thanks!
    MacBook   Mac OS X (10.4.6)   PocketMac/BlackBerry

    When you go through the sync process, do you see any records that the sync recognizes and says it will move to your Mac?
    What happens during the sync?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Restoring Address Book files?

    All:
    I managed to delete a bunch of address book entries. I have a printout out them (dozens) but I'd rather restore than rekey them back in.
    Via Time Machine, I restored (to my desktop) a copy of the Metadata folder, which has the individual vcard files. So, I think it's simple as copying the missing cards back into my Macintosh HD/users/username/Library/Application Support/Addressbook/Metadata folder. Wrong! When I launch Address Book, the restored file isn't there.
    What extra step(s) am I missing?

    Ok, that was stunningly easy. At work, I'm a sysadmin and I'm used to 'peaking behind the curtain' all the time. I overthought this restore process!
    I had the app in question open (Address Book), clicked on the Time Machine icon on the dock, and went back several months and found the cards I'm looking for! Other than some latency issues (my TM disk is in the basement, hanging off of my Airport Extreme), this process went very well. Thanks!

  • HT1338 address book, max number of contacts allowed???

    I'm importing some Vcards into my macbook air address book, but its stock on 1043, is there a limit for the contacts that can be manage by this application?

    This isn't an iSync question, but there is no forum for Address Book, at least not one I found.
    http://discussions.apple.com/forum.jspa?forumID=753
    i have a group with 160 contacts in it; when I try to send a group email it bounces back to me with the message "Too many contacts". I looked up this question in Address Book Help but there's nothing there to answer it.
    That's because it's not an Address Book issue - it's an email issue. You don't say who your email provider is, but most impose limits on the number of contacts a single email can be sent to, to prevent spammers from sending out emails to hundreds or thousands of people in one go.
    Is there a maximum number?
    Most likely.
    If so, what is it?
    You'd have to contact your email provider to ask them.
    Can I increase it?
    Most likely not.

  • Address Book doesn't open in Mavericks

    Since upgrading to OS X 10.9.2 the Address Book doesn’t open.  I get the error message:  You can’t use this version of the application “Address Book” with this version of OS X.  You have “Address Book” 5.0.3.  The question mark sends me to the Apps store but there’s no Apple Address Book there.  My updates are current.  How do I fix it?

    Hello Tom,
    Thank you for the question.  Address Book was called Contacts starting with OS X Mountain Lion.  When looking in your Applications folder on your Mac, look for the Contacts application to manage your contacts:
    Contacts (Mavericks): Manage your contacts
    http://support.apple.com/kb/PH15068
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Address book spontaneously deletes group

    I've had this happen three times now:
    Address book just spontaneously deletes one of my groups (two times with the same group).
    Or else the group just vanishes somehow.
    I'm just switched to Mail after using Entourage for five years, so I'm not a power user or anything. I may be missing something.
    any ideas appreciated.
    Ken

    You may have to delete the address book plist file, and restart your mac. You can find it here:
    Users/Username/Library/Preferences/com.apple.AddressBook.plist

  • Bizarre address book problem

    About 80% of my address book entries have lost their phone numbers. Names remain, but no numbers.
    Unfortunately, I didn't know about this problem until the machine went through a full cycle of of online and offline backups, so all three of my address book backups along with .Mac all have the same catastrophic problem!
    I have used Macs since 1984 and am quite knowledgeable about backup, software, etc. I cannot begin to understand what might have happened.
    Any comments or suggestions would be appreciated.

    Try something to see if they are really lost or just temporarily(?) invisible:
    1. Launch Address Book, and export one of the entries, that is missing its phone numbers, to a .vcf card
    2. Launch Terminal.app
    3. In Teminal.app, type cat, but don't hit the return (⏎) key just yet.
    4. Type a spacebar character after "cat", and still don't hit the return (⏎) key just yet.
    5. Drag the newly created .vcf card into Terminal's window; now type ⏎
    6. Are the phone numbers still in there? Hopefully, they are.
    7. Back in Address Book, go to Peferences (⌘,)
    8. You should see several icons across the top of the preferences window: General, Template, vCard, Phone, LDAP, and Sharing. If you don't see these icons, click on the oval-shaped (capsule-shaped) button in upper-right-hand corner of the preferences window -- that should make them become visible if they are not.
    9. Click on the Template icon. If "phone" not shown there, goto the pulldown menu and see if it is a selected field (if purportedly an active field, it will be grayed out in this menu)
    HTH

  • Address Book won't import local area code

    I'm trying to export my contact info from Palm Desktop to Address Book. Everything works fine, expect that AB doesn't import a contact's area code if it's my local area's code. In this case AB only imports a contact's 7 digit phone number. This isn't a problem with area codes outside of my local code, --they import just fine, and I get the whole 10 digits.
    I've tried exporting both vCards and text files. By opening the text file with TextEdit, I have verified that Palm Desktop is indeed exporting the area codes --both my local code and distant ones. Yet when I import that same file into AB, contacts in my local area are stripped of the area code.
    Any ideas?
    Thanks in advance, --Brian
    12" Powerbook G4   Mac OS X (10.4.8)  

    Thanks for your questions/suggestions. I think they have helped lead me in the right direction over the past 24 hours, though I still don't have a solution.
    To make the long story short:
    I believe the problem lies in the fact that as I've added contacts to Palm Desktop over the years, I've not included an area code if they were in my area. Now I'm switching to AB since it can sync with my new cell phone, and I'm needing area codes for all calls. Rather than enter my local code for hundreds of contacts, I've used a Palm preference whic sets up a "default area code."
    What I have discovered is that contacts for which I have manually entered an area code transfer to AB just fine. Contacts for which this preference provides the area code lose this information in the transfer. This is baffling, because the two cases look identical when viewed with Textedit, --the area code is visible plain as day in either situation.
    Just as puzzling --when AB imports a contact it gives a chance to review the information if the card is a duplicate. When I perform this review a "Text File Import" window appears. In this window areas codes always appear, --whether manually entered or provided by the Palm preference. However, in the "Reviewing Card" window which follows, cards which had Palm preference provided area codes have inexplicably lost those codes, while those with manually entered codes have retained them.
    Any further thoughts?
    Thanks some more, --Brian
    12" Powerbook G4   Mac OS X (10.4.8)  

  • Source code for address book

    hi everyone,
    i have to make a contact wizard for iphone, i have allready designed the view for contact wizard using navigation controller, there are 3 pages total which includes UITextFields, PickerView, and Table View.
    Now i dont know where to write code for add contacts in address book database.
    can any one help me by some code sample...?????
    i have written code in a function which is called on the Navigation toolbar Button
    the code is
    ABRecordRef aRecord = ABPersonCreate();
    CFErrorRef anError = NULL;
    ABRecordSetValue(aRecord, kABPersonFirstNameProperty,
    CFSTR("Jijo"), &anError);
    ABRecordSetValue(aRecord, kABPersonLastNameProperty,
    CFSTR("Pulikkottil"), &anError);
    if (anError != NULL) {
    NSLog(@"error while creating..");
    CFStringRef firstName, lastName;
    firstName = ABRecordCopyValue(aRecord, kABPersonFirstNameProperty);
    lastName = ABRecordCopyValue(aRecord, kABPersonLastNameProperty);
    ABAddressBookRef addressBook;
    CFErrorRef error = NULL;
    addressBook = ABAddressBookCreate();
    BOOL isAdded = ABAddressBookAddRecord (
    addressBook,
    aRecord,
    &error
    if(isAdded){
    NSLog(@"added..");
    if (error != NULL) {
    NSLog(@"ABAddressBookAddRecord %@", error);
    error = NULL;
    BOOL isSaved = ABAddressBookSave (
    addressBook,
    &error
    if(isSaved){
    NSLog(@"saved..");
    if (error != NULL) {
    NSLog(@"ABAddressBookSave %@", error);
    CFRelease(aRecord);
    CFRelease(firstName);
    CFRelease(lastName);
    CFRelease(addressBook);
    But it is showing many errors.
    can any one give me some advice how to manage it?

    You probably won't get much help here... this is a user forum, not a developer or programmer forum.

  • ICloud to Mac Address Book - Two Questions

    Okay, I have learned/accepted that iCloud is not the sync'ing deal that MobileMe was (missed that in the fine print as I have been a loyal .mac user from its inception and like the MM syncing). I understand that everything is updated in the cloud and pushed to various devices (for me, iPhone 4S, new iPad and 2009 MBP).  So, how is it possible for my iCloud address book to have more contacts than my MBP address book?  Wouldn't all of the ones in iCloud be pushed to the MBP?  The only thing I can think is that before I understood the concept that there are two address books resident on the MBP, I starting deleting what I thought were duplicates since I wasn't able to merge them due to two different sources.  I could not find a way at that time to tell me which line was from what source.  Then, once I get the two address books matching - mostly to ensure that I am not missing anything in the iCloud one - what purpose does the Mac based address book serve?  I just had a nightmare of dragging various cards from my iCloud address page on the right into the iCloud group on the left and only to realize after doing at least 20 cards that after the first one, the left page registers back up putting the Mac based group across from the iCloud contact list so I dropped many of them into the Mac group instead of the iCloud group. The iCal doesn't maintain a Mac version and an iCloud version, why does the address book?  BTW, all software on all devices is up to date as of this posting.

    Please pardon what may be a silly question.  This is my first ever post...
    I was thinking about deleting "On My Mac" address book per your above instructions, and sticking with the one iCloud contacts.  The problem I am afraid of running into is this:  In iTunes, when I sync contacts, the groups that show available for syncing all come from "On My Mac".  If I delete from the Mac, will that make my "Contacts" icon on my iPad 'dead'?  Thereby, forcing me to log onto iCloud to view my Contacts, instead of a handy shortcut??? 
    Or will I simply get to forgo the iTunes syncing... and the "contacts" icon on my iPad will reflect what was synced thru iCloud?
    If the latter is true, does that simply mean I will need to recreate my "groups" in iCloud?
    Thanks in advance, I certainly need some guidance.

  • Question: about to purchase ipad air - how do I migrate contacts,bookmarks,and address books from either an iMac or old macbook?

    Question: about to purchase ipad air - how do I migrate contacts,bookmarks,and address books from either an iMac or old macbook?

    Set up iCloud on both devices
    How to set up iCloud on all your devices
    http://www.apple.com/icloud/setup/

  • Simple question; Mac Server Setup for Mail, iCal and Address Book Services.

    Hi Guys;
    I'm new to the Mac Server world and need a few questions answered.
    I have purchased a new Mac mini Server for hosting File, Web, Mail, iCal and Address Book Services.
    I’m comfortable setting up File and Web Services however I’m a bit uneasy setting up Mail, iCal and Address Book services to be access locally and remotely(via the internet).
    My current setup is;
    Internet connection (Dynamic IP) -> Router -> Mac mini Server.
    I have purchased a domain name (Thornton-net.com) from DynDns.com + a custom DNS service as I can setup my router to update my domain’s IP address automatically.
    I can access File and Web Services remotely (thortnon-net.com) perfectly without any issues via the Port Forwarding feature of the Router.
    If I setup Mail, iCal and Address Book Services -> will Mail, iCal and Address Book clients be able to access these services hosted by the server via Thornton-net.com?
    Message was edited by: Allan.Thornton

    Welcome to the forums.
    For mail services (and specifically for your outbound mail to be accepted by other mail servers) your mail server needs to have a static IP address and matching forward and reverse and MX records, or a tunnel to a static IP (with matching DNS), or you need another mail server where you have an authorized relay. Without that, your mail will be considered a spam engine, and dropped.
    Additionally, your particular tier of service with your ISP (with a static IP) will generally allow server-oriented access and server-oriented network traffic, where a residential or other tier of service (with a dynamic IP addresses) can be firewalled.
    The ISP controls the "high ground" of the network connections here, so you pretty much get to play by their rules and requirements. If they don't offer static IP, then (presuming their T&Cs permit it) you get to tunnel (via IPv6, for instance) to a tunnel broker, and receive your network traffic via that (and with matching DNS) point of presence. That could well be a tunnel for your mail at whichever your DNS provider is here, because you'll have issues with your dynamic address. (You get to sort out if they offer that.)
    Far and away the easiest approach (if you want to host this stuff yourself) is to work with the ISP. They're inherently involved in your network, and they and they alone have full control over your reverse DNS configuration.

Maybe you are looking for

  • ICal Search doesn't find events in the "distant" future !!!

    I posted this in LEOPARD and at the end, no resolution and "Fred II" recommended I post this is this Snow Leopard discussion - he sent me this link -- appreciate any comments! Here's a bit of a disturbing one: I use iCal (Leopard, so iCal 3.0.8 1287)

  • Row Level Security using BO SDK - Dynamic Group and Criteria (where clauses)

    To the Universe Gurus out there: I have a rather daunting task of implementing a Row Level Security on a number of tables within our project using BO XI R2 SP2 with SQLServer 2005. Given the nature of the requirements around this (listed below), I am

  • Oracle messenger web interface

    Does Oracle messenger has an interface that can be integrated with a Portal page? Essentially, the need is to have a messenger window always available within a portal/web page instead of invoking the client for sending/receiving messages. If Oracle m

  • Finder Find

    Is anyone else annoyed by the finder find (command F)? Half the time it doesn't find files that I know are there. I know it doesn't find system files by default, but I know how to turn that on. Even so, it still doesn't always work. It's a shame I ha

  • Is there php-mcrypt package in the repository?

    I was trying to install php-mcrypt package while installing LAMP as the way described in the wiki. It seems there is no package available. It is not available in AUR either, I guess so. $ sudo pacman -S php-mcrypt resolving dependencies... looking fo