I have a applescript studio application that opens a drawer that contains a ABPeoplePickerView for looking up address book information. The drawer opens fine, but I am trying to collect the information from the selected contact back into my main window. I keep getting a error “nothing selected” due to the debugging that I have put into my script. It seems to me that I have the not entered the proper location when trying to get the “uniqueId” of the contact selected. Here is my script and some screen shots. Any help would be appreciated.
on clicked the_object
set object_name to name of the_object as Unicode text
my update_status("clicked " & object_name)
set the_id to my get_id()
if the_id = false then error "nothing selected"
if object_name = "open" then
open location "addressbook://" & the_id
else if object_name = "info" then
display dialog "hello"
set the_record to call method "getABDictFromID:" of class "ABHandler" with parameter the_id
set the_info to {"first name: ", the_record's first_name, return, "last name: ", the_record's last_name, return, "company: ", the_record's company, return, "email: ", the_record's email}
set contents of text view 1 of scroll view 1 of window "main" to (the_info as Unicode text)
set contents of text field "customer" of window "main" to the_record's company
set contents of text field "contact" of window "main" to the_record's last_name
end if
--on error the_error
log "Error: " & the_error
--end try
end clicked
on should quit after last window closed the_object
return true
end should quit after last window closed
on update_status(the_message)
if debug_me then log the_message
end update_status
on get_id()
try
set selected_records to call method "selectedRecords" of (view "people_picker" of content view of drawer "Drawer")
return call method "uniqueId" of (item 1 of selected_records)
display dialog (call method "uniqueId" of (item 1 of selected_records))
on error
return false
end try
end get_id
This is a screen shot of my IB window.
http://img.photobucket.com/albums/v122/petekin74/Picture2-1.png
My button is named “info”
My Drawer’s name is “Drawer”
My ABPeoplePickersViews’s name is “people_picker”
My View’s name is “View”
Thanks Again