Sorry I posted This in the wrong forum:
I’m putting together a script to recuperate information from address book and post it into Filemaker. I know the code is really rough but I’m new to this. I’m able to get the address information but i’m unable to specify with the label’s “work” or “home” I’m also unable to specify which email address or phone numbers I’d like. I also feel I’m repeating myself a lot so i’m sure that there is some cleaning up to do. Could anyone please give me a hand.
(Thanks to StefenK and Dylan Webber for the list code.)
[code]try
set Lst to {}
tell application “Address Book”
set thePeopleList to every person
repeat with i from 1 to count of thePeopleList
set thename to (name of item i of thePeopleList)
set the end of Lst to thename
end repeat
end tell
set unsortedList to Lst
set old_delims to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {ASCII character 10}
set theList to paragraphs of (do shell script “echo " & quoted form of (unsortedList as string) & “| sort -d -f”)
set AppleScript’s text item delimiters to old_delims
theList
set thePersonChosen to (choose from list theList with prompt " Please choose a Person :”)
tell application “Address Book”
set thePersonId to every person whose name is thePersonChosen as string
set thePersonFirstName to (first name of (item 1 of thePersonId)) as string
if thePersonFirstName is missing value then return “” as string
set thePersonLastName to (last name of (item 1 of thePersonId)) as string
if thePersonLastName is missing value then return “” as string
set thePersonFullName to (name of (item 1 of thePersonId)) as string
if thePersonFullName is missing value then return “” as string
set thePersonWorkAddressStreet to (street of address 1 of (item 1 of thePersonId)) as string
if thePersonWorkAddressStreet is missing value then return “” as string
set thePersonWorkAddressZip to (zip of address 1 of (item 1 of thePersonId)) as string
if thePersonWorkAddressZip is missing value then return “” as string
set thePersonWorkAddressVille to (city of address 1 of (item 1 of thePersonId)) as string
if thePersonWorkAddressVille is missing value then return “” as string
set thePersonWorkAddressPays to (country of address 1 of (item 1 of thePersonId)) as string
if thePersonWorkAddressPays is missing value then return “” as string
set thePersonHomeAddressStreet to (street of address 2 of (item 1 of thePersonId)) as string
if thePersonHomeAddressStreet is missing value then return “” as string
set thePersonHomeAddressZip to (zip of address 2 of (item 1 of thePersonId)) as string
if thePersonHomeAddressZip is missing value then return “” as string
set thePersonHomeAddressVille to (city of address 2 of (item 1 of thePersonId)) as string
if thePersonHomeAddressVille is missing value then return “” as string
set thePersonHomeAddressPays to (country of address 2 of (item 1 of thePersonId)) as string
if thePersonHomeAddressPays is missing value then return “” as string
set thePersonCompany to (organization of (item 1 of thePersonId)) as string
if thePersonCompany is missing value then return “”
set thePersonJob to (job title of (item 1 of thePersonId)) as string
if thePersonJob is missing value then return “”
set thePersondepartment to (department of (item 1 of thePersonId)) as string
if thePersondepartment is missing value then return “”
set thePersonWorkPhone to (phone of (item 1 of thePersonId)) as string
if thePersonWorkPhone is missing value then return “”
end tell
on error
error “Failed to retrieve Contact details”
end try
try
tell application “FileMaker Pro Advanced”
activate
set the contents of field “Nom de Famille” of the current record ¬
to thePersonLastName
set the contents of field “Prénom” of the current record ¬
to thePersonFirstName
set the contents of field “Service” of the current record ¬
to thePersondepartment
set the contents of field “Poste” of the current record ¬
to thePersonJob
set the contents of field “T Rue” of the current record ¬
to thePersonWorkAddressStreet
set the contents of field “T Code Postale” of the current record ¬
to thePersonWorkAddressZip
set the contents of field “T Ville” of the current record ¬
to thePersonWorkAddressVille
set the contents of field “T Pays” of the current record ¬
to thePersonWorkAddressPays
set the contents of field “Rue” of the current record ¬
to thePersonHomeAddressStreet
set the contents of field “Code Postale” of the current record ¬
to thePersonHomeAddressZip
set the contents of field “Ville” of the current record ¬
to thePersonHomeAddressVille
set the contents of field “Pays” of the current record ¬
to thePersonHomeAddressPays
set the contents of field “Téléphone Entreprise” of the current record ¬
to thePersonWorkPhone
set the contents of field “Téléphone Mobile” of the current record ¬
to thePersonWorkCell
end tell
on error
error “Failed to add contact details to filemaker”
end try[/code]