04. V2 – Pulling Contacts [4:26]

Description: This video provides an overview of how to pull records from Apple Address Book into FileMaker using the Address Book Manipulator.  This video was made with version 2 of the plug-in. Additional functionality is now available with version 3.

Transcript:

0:00 Thanks for choosing Productive Computing for your FileMaker needs. This video demonstrates pulling information from the Address Book into FileMaker. We will be using the demo database included in the PCAB_Disk Image available from the Address Book Manipulator.com website.

0:17 There are four scripts used in pulling contacts from the Address Book. The first determines which type of records we are going to search. The second performs the search. The third iterates through the found set. And the fourth actually pulls the individual contact information into FileMaker.

0:34 I’ll begin by performing a search that I know will bring back a small set of records. We see here that the first step is to make sure the plug in is installed by calling the plug in checker script. Next we make sure we are also searching for contact records. I’ll step into the pull contact script where we will search for records and move through the found set.

0:56 First the search is performed. Then we test the result to make sure the search actually found records and didn’t error. Next we clean out the existing records in the demo file to make way for our new record set. And finally we will prepare to iterate through the found set by calling the PCAB_OpenFirstRecord function. This function returns either the Address Book ID for an address book record, the string end if there are no records, or the error string. We will exit the loop if either end or an error string is returned.

1:32 We then pass the Address Book ID to the populate contact field script, where we will pull the information from the Address Book record. This script first goes to the proper layout for entering the information, then a test is performed to see if we need to create a new record or not. And finally the desired record is opened for reading or writing.

1:53 The first set of data pulled from the record are the single value properties such as creation date, first name, and last name etc. These are called single value properties because they will only ever have one single value. The function PCAB_GetValueForProperty is used to get the single value. The name of the property is passed to the function, and the value for the property is returned.

2:20 The next set of information the script retrieves are the multi valued properties. These properties such as phone numbers and email addresses are those that can contain more than a single value. To get to these values we first use the PCAB_OpenFirstMVProperty. This function returns an identifier which we refer to as the UID, for the first value in the property. The UID is then used to access the desired properties value and label with the functions PCAB_GetValueForUID and PCAB_GetLabelForUID.

2:57 Both functions take the name of the property for the first parameter and the UID as the second parameter. To get to the successive values in the property we call the PCAB_OpenNextMVProperty. Which returns the UID of the next property. Using this UID we then again call the get value and get label functions.

3:29 Finally, when pulling addresses the process is nearly the same as pulling any other MV Property. We still use the PCAB_OpenFirstMVProperty and PCAB_OpenNextMVProperty functions to get the UID. However; when retrieving the value for the address, we need to include an extra parameter in the PCAB_GetValueForUID function. This third parameter is the key or the part of the address that we are after. Use the string street, city, state, zip or country to get the desired part of the address. I’ll finish the pull to exam the results. You see that we have successfully retrieved the correct contact information for the records.

4:11 This concludes this video. Please be sure to visit the rest of the instructional videos at AddressBookManipulator.com. Thanks for watching.